我有代码:
let a = {a: 'a', b: 'b'};
let b = {c: 'c', d: 'd'};
let c = {...a, ...b};
In chrome/firefox/...其显示:c = {a: 'a', b: 'b', c: 'c', d: 'd'}
, 但在微软边缘它抛出错误Expected identifier, string or number
.
我尝试使用cdn.polyfill.io
and https://babeljs.io/docs/en/babel-polyfill
但没有运气。
我可以做什么来运行我的webpack代码在微软边缘?
从 79 开始,它应该在 Edge 中可用,不需要任何转编译器(如 Babel)(但不是 IE,不要混淆它们)。
https://caniuse.com/#feat=mdn-javascript_operators_spread_spread_in_object_literals https://caniuse.com/#feat=mdn-javascript_operators_spread_spread_in_object_literals
也就是说,在大多数情况下你可以使用Object.assign()
相反,如果你想要 -
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
那么你的代码将是:
let a = {a: 'a', b: 'b'};
let b = {c: 'c', d: 'd'};
let c = Object.assign(a,b)
console.log(c)
Object.assign()
从 Edge 12 开始支持:
https://caniuse.com/#feat=mdn-javascript_builtins_object_assign https://caniuse.com/#feat=mdn-javascript_builtins_object_assign
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)