国内外VPS
主机测评与优惠

Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode错误的解决办法

最近笔记本电脑坏了送修,临时找了一台台式电脑办公,结果之前写好的前端代码无法正常运行了,看了一下提示JS错误:

Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outs

这个错误是因为当前电脑的浏览器版本不支持ES6语法,解决办法有以下两种:

1.如果不涉及到代码逻辑的话,使用var替换let即可。

2.在使用let关键字的代码块第一行加入下面代码,注意不要删除单引号。

'use strict';

赞(0)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode错误的解决办法》
文章链接:https://www.liuzhanwu.com/3281.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

登录

找回密码

注册