[英]Destructuring statement in chrome/chromium 44 not being recognised
As far as I know, this is valid EcmaScript6: 据我所知,这是有效的EcmaScript6:
let obj = {foo: "foo", bar: "bar"};
let {foo, bar} = obj; // <- Syntax error here
Firefox runs this code just fine, but both Google Chrome and Chromium give me this error: Firefox可以很好地运行此代码,但是Google Chrome和Chromium都会出现此错误:
Uncaught SyntaxError: Unexpected token {
I know in firefox, scripts tags have to be flagged with "version=1.7" in the type attribute for this to work, but in Google Chrome this results in the script getting ignored. 我知道在firefox中,脚本标签必须在type属性中标记为“ version = 1.7”才能起作用,但是在Google Chrome中,这会导致脚本被忽略。 A normal script tag gives this error.
正常的脚本标签会出现此错误。
Does this mean this feature is not implemented in Google Chrome? 这是否表示该功能未在Google Chrome浏览器中实现? Or am I missing something?
还是我错过了什么?
That's right. 那就对了。 Currently, it isn't supported yet.
目前尚不支持。
https://devdocs.io/javascript/operators/destructuring_assignment https://devdocs.io/javascript/operators/destructuring_assignment
Although Chrome doesn't support some new features of ES6 (check this table to see what is already supported on different browsers), you can use a polyfill/plugins to enable certain features on Chrome. 尽管Chrome浏览器不支持ES6的某些新功能(请查看此表以查看不同浏览器已支持的功能),但是您可以使用polyfill /插件在Chrome上启用某些功能。 You can find polyfill and plugins on Babel .
您可以在Babel上找到polyfill和插件 。 Just read through the plugins documentation and implement the ones you want.
只需阅读插件文档并实施所需的插件即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.