PolymerTS属性装饰器错误

时间:2016-10-21 12:19:10

标签: javascript meteor ecmascript-6 polymer babel

我使用带有es6和babel的PolymerTS https://github.com/nippur72/PolymerTS#property装饰器。 当我尝试设置用@property装饰器

描述的属性时

Uncaught TypeError: Cannot assign to read only property 'suggestionSelected' of object '#<suggestions-selector>'(…)

readonly标志为假

一些代码示例,但所有类似情况下的错误相同

@property({type: Number, value: -1})
suggestionSelected;

onInputKeypress(e) {
    if (keycode(e) === 'down') {
        e.preventDefault();
        this.$.suggestions.selectNext();
    } else if (keycode(e) === 'up') {
        e.preventDefault();
        this.$.suggestions.selectPrevious();
    } else if (keycode(e) === 'enter') {
        this.fire('search', {query: this.$.input.value});
        this.suggestions = [];
        this.suggestionSelected = -1;
    } else {
        this.suggestionSelected = -1; // error here
        this.fetchSuggestions();
    }
}

```

0 个答案:

没有答案