浏览器支持Javascript中的类语法
下面是语法浏览器支持Javascript中的类语法,javascript,google-chrome,firefox,browser,ecmascript-6,Javascript,Google Chrome,Firefox,Browser,Ecmascript 6,下面是语法 class Polygon { constructor(height, width) { this.height = height; this.width = width; } } var Polygon = class { constructor(height, width) { this.height = height; this.width = width; } }; var Polygon = class Polygo
class Polygon {
constructor(height, width) {
this.height = height;
this.width = width;
}
}
var Polygon = class {
constructor(height, width) {
this.height = height;
this.width = width;
}
};
var Polygon = class Polygon {
constructor(height, width) {
this.height = height;
this.width = width;
}
};
--
chrome和firefox都不支持
SyntaxError:意外的令牌类(…)
已安装chrome版本47.0.2526.80 m
已安装firefox版本44.0a2(2015-12-12)
截至2015年12月14日,类
&扩展
关键字得到支持的浏览器版本是什么?
- 铬42.0
- FirefoxGecko夜间构建
- 边缘13
- 狩猎9
Javascript类规范:
为什么不使用支持的东西呢,
function Polygon
@SpencerWieczorek基于类的范例看起来更容易(接近真实世界)构建抽象我认为你需要有严格的模式才能在Chrome上工作。你知道,浏览器(跨浏览器)需要多长时间吗要支持类
语法?真正的问题是-要多久才能有足够多的人拥有支持类
语法的浏览器。我使用的是chrome版本47.0.2526.80M
。这是否支持class
语法?是的,但仅在严格模式下。请使用“dsoop.js”。它使用类语法,再加上更多,然后在幕后转换东西,使其与每个浏览器兼容!