Internet Explorer 11 JavaScript Let语句 [英] Internet Explorer 11 JavaScript Let Statement

查看:84
本文介绍了Internet Explorer 11 JavaScript Let语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有相当复杂的代码,该代码通过"for"循环依次执行多个AJAX调用.该代码之所以有效,是因为在将范围分配给循环索引时使用了"Let"语句. (让i = 0; i< 2; i ++){}.

I have rather complex code that is executing a multiple AJAX call in sequence through the 'for' loop. This code works because I use 'Let' statement when assigning scope to a loop index. (let i = 0; i < 2; i++) { }.

但是,让"给了我期望的"; Internet Explorer 11中的错误,虽然代码在其他浏览器中可以正常工作,但我尝试将"let"移出循环,但仍然失败,无论在何处使用该语句,无论循环如何,它似乎都失败了,请让我知道这是什么解决方法,因为IE 11应该与'Let'语句兼容.

However, 'Let' is giving me " Expected ';' error in Internet Explorer 11, While the code is working perfectly in other browsers. I have tried to move "let" out of the loop but it still fails, it seem to fail wherever the statement is used regardless of the loop. Please let me know what is the workaround for this as IE 11 is supposed to be compatible with 'Let' statement.

推荐答案

请参见此ES6支持表格. Internet Explorer 11在 for/for-in循环迭代范围中不支持let.

See this ES6 support table. Internet Explorer 11 does not support let in for/for-in loop iteration scope.

您需要采用其他方法.

此答案列出了许多您可以手动实施的选项.

This answer lists a number of options you could implement manually.

您还可以使用 Babel 之类的工具将ES6或更新版本的JavaScript转换为ES5.

You could also use a tool like Babel to transpile your ES6 or newer JavaScript into ES5.

这篇关于Internet Explorer 11 JavaScript Let语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆