我正在尝试让 Aurelia 的入门应用程序正常工作,但我在第一页就遇到了错误。 http://aurelia.io/get-started.html
有问题的代码:
export class Welcome {
heading = 'Welcome to the Aurelia Navigation App!';
firstName = 'John';
lastName = 'Doe';
get fullName(){
return `${this.firstName} ${this.lastName}`;
}
welcome(){
alert(`Welcome, ${this.fullName}!`);
}
}
错误 :
[21:46:19] Plumber found unhandled error:
SyntaxError in plugin 'gulp-babel'
Message:
D:/workspace/aurelia/navigation-app/src/app.js: Unexpected token (2:10)
1 | export class Welcome {
> 2 | heading = 'Welcome to the Aurelia Navigation App!';
| ^
3 | firstName = 'John';
4 | lastName = 'Doe';
5 |
[21:46:19] Finished 'build-system' after 20 ms
我不得不说我在windows上,它可能会造成一些麻烦。
我通过将变量放在构造函数中“解决”了这个问题。但是上面的语法不是有效的 ES6 吗?是 ES7 还是什么还不能用?
我知道这段代码看起来很奇怪但我不是作者,它是来自 Aurelia 教程的原始代码