IE 11 Script1002 Array.Filter(x => ...)(箭头函数)
IE 11 Script1002 Array.Filter(x => ...) (Arrow functions)
我在 IE11 中收到一条错误消息,但在 chrome 中却没有,错误是:
Script1002 Syntax error
我的代码如下
var selectedRoles = vm.roles.filter(x => x.id === role.id);
错误的行号和列号提示是IE11不喜欢的箭头函数=>
。但是它在 Chrome 和 Edge
中工作正常
即11不支持arrow functions
尝试
var selectedRoles = vm.roles.filter(function(x) { return x.id === role.id; });
不支持 IE arrow function check browser compatibility here。如果您需要 IE 支持,请改用普通函数。
var selectedRoles = vm.roles.filter(function(x) {
return x.id === role.id
});
箭头功能在 IE 11 中尚不支持。您可以参考这些兼容性 table: https://kangax.github.io/compat-table/es6/ 以详细了解在何处支持的内容以及支持的程度。
使用 pollyfills 或 PRE-ES6 兼容代码,例如
var selectedRoles = vm.roles.filter(function(x) {
return x.id === role.id
});
我在 IE11 中收到一条错误消息,但在 chrome 中却没有,错误是:
Script1002 Syntax error
我的代码如下
var selectedRoles = vm.roles.filter(x => x.id === role.id);
错误的行号和列号提示是IE11不喜欢的箭头函数=>
。但是它在 Chrome 和 Edge
即11不支持arrow functions
尝试
var selectedRoles = vm.roles.filter(function(x) { return x.id === role.id; });
不支持 IE arrow function check browser compatibility here。如果您需要 IE 支持,请改用普通函数。
var selectedRoles = vm.roles.filter(function(x) {
return x.id === role.id
});
箭头功能在 IE 11 中尚不支持。您可以参考这些兼容性 table: https://kangax.github.io/compat-table/es6/ 以详细了解在何处支持的内容以及支持的程度。
使用 pollyfills 或 PRE-ES6 兼容代码,例如
var selectedRoles = vm.roles.filter(function(x) {
return x.id === role.id
});