IE 11 Script1002 Array.Filter(x => …) (Arrow functions)

前端 未结 3 907
死守一世寂寞
死守一世寂寞 2021-02-06 20:42

I get a error message in IE11 but not in chrome the error is:

Script1002 Syntax error

My code is as follows

<
相关标签:
3条回答
  • 2021-02-06 21:22

    The arrow function is not supported yet in IE 11. You can refer to these compatibity table: https://kangax.github.io/compat-table/es6/ to get an overview what is suuported where and to what extent in a detailed fashion.

    Use pollyfills or a PRE-ES6 compatible code, e.g.

    var selectedRoles = vm.roles.filter(function(x) {
       return x.id === role.id
    });
    
    0 讨论(0)
  • 2021-02-06 21:24

    ie 11 not support arrow functions

    try

    var selectedRoles = vm.roles.filter(function(x) { return x.id === role.id; });
    
    0 讨论(0)
  • 2021-02-06 21:27

    IE not supported arrow function check browser compatibility here. If you want IE support then use the normal function instead.

    var selectedRoles = vm.roles.filter(function(x) {
      return x.id === role.id
    });
    
    0 讨论(0)
提交回复
热议问题