Javascript ES6课程不包括';我不能在铬47上工作
Google Chrome声称从版本42开始就支持ES6类,但当我在控制台中从下面运行简单代码时,它给出了Javascript ES6课程不包括';我不能在铬47上工作,javascript,google-chrome,ecmascript-6,Javascript,Google Chrome,Ecmascript 6,Google Chrome声称从版本42开始就支持ES6类,但当我在控制台中从下面运行简单代码时,它给出了未捕获的SyntaxError:Unexpected token class(…): class Polygon { constructor(height, width) { this.name = 'Polygon'; this.height = height; this.width = width; } Firefox也不起作用。微软的边缘工作得很好。这
未捕获的SyntaxError:Unexpected token class(…)
:
class Polygon {
constructor(height, width) {
this.name = 'Polygon';
this.height = height;
this.width = width;
}
Firefox也不起作用。微软的边缘工作得很好。这正常吗?您是否处于“严格使用”模式
ES6类通过为类提供干净、标准化的语法来解决这个问题。这种新语法在Chrome 42中提供,用于以严格模式编写的JavaScript
@VSG24我没有启用任何标志,
(function(){“use strict;return class Polygon{}})(
在Chrome47中对我很好。您确定您的“use strict;”声明放置正确吗?你使用的是旧版本的Chrome吗?@apsillers我宣布“严格使用”代码>在错误的位置。现在可以了。