随着上周 Sencha CMD 和 ExtJS 6.5 的发布,我对在我的 ExtJS 项目中使用 ES6 类感到非常兴奋。话虽如此,我能找到的唯一一种关于如何在 ExtJS 中实现 ES6 类的“文档”是this post。从去年十月开始。尽管它给出了一个示例,但我认为我遗漏了一些东西,因为我在构建过程中遇到了以下错误。
[ERR] C2001: Closure Compiler Error (Character '@' (U+0040) is not a valid identifier start char) -- path/to/project/Foo.js:4
[ERR] C2001: Closure Compiler Error (primary expression expected) -- path/to/projectFoo.js:4:7
Foo.js
import { define } from 'extjs-kernel'; // module names not final
import { Observable } from 'extjs-core';
import { Base } from 'app-some';
@define({
mixins: Observable,
config: {
value: null
}
})
export default class Foo extends Base {
updateValue (value, oldValue) {
this.fireEvent('valuechange', value, oldValue);
}
}
我是否缺少 CMD 命令?如果没有,任何进一步的解释将不胜感激。
注意
我在 app.json
中的 output
属性如下所示:
"output": {
"base": "${workspace.build.dir}/${build.environment}/${app.name}",
"appCache": {
"enable": false
},
"js": {
"version": "ES6"
}
},
最佳答案
In Ext JS 6.5 and Sencha Cmd 6.5 (https://www.sencha.com/blog/announcing-ext-js-6-5-and-sencha-cmd-6-5-ga) you can use pretty much all the ES6 syntax, but support for ES6 modules is a version 7 thing.
来源(来自您提到的同一帖子的 Sencha 评论):https://www.sencha.com/blog/ext-js-and-es201567-modernizing-the-ext-js-class-system/#comment-65507
关于javascript - ExtJS 6.5类系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44027237/