function animate({ draw1, duration1 }) {… causes expected identifier (script1010) error in IE11 - Object Destructuring support in IE [duplicate]

柔情痞子 提交于 2021-02-09 11:54:48

问题


I am having issues with a site build where the page is not displaying properly in IE11. The site displays correctly in chrome, firefox, and edge.

The error seems to break all the javascript from the file of the error. The file is responsible for handling parts of the layout, so when it fails it causes various sections on the page to not render properly.

The error message is "Script1010" and points to the following line of code:

function animate({ draw, duration }) {
...
}

I've not been able to identify why IE cannot process this line. The closest thing to answer I've seen is the following post that suggests that "draw" or "duration" might be reserved words in IE. But changing them caused the same error to occur.

Any suggestions or pointers?

EDIT: Thanks for the replies. Figured I would clarify the question as a foot note for similar searches, or even just for myself. As pointed out below, the question boils down to "Does IE support ES6 object destructuring?". Turns out object destructuring does not work in IE.


回答1:


You are using ES6 to destructure the arguments. Internet Explorer does not support ES6.

You'll either have to rewrite it using ES5 or use a transpiler like Babel to transpile your code into ES5.

EDIT: If this is the only occurrence of ES6, I'd suggest rewriting it, but otherwise I'd use Babel.

function animate(arg) {
  var draw = arg.draw
  var duration = arg.duration
  ...
}


来源:https://stackoverflow.com/questions/53198577/function-animate-draw1-duration1-causes-expected-identifier-script10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!