未捕获的SyntaxError:在严格模式之外尚不支持块范围的声明(let,const,function,class) [英] Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

查看:127
本文介绍了未捕获的SyntaxError:在严格模式之外尚不支持块范围的声明(let,const,function,class)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的JS控制台在浏览器中弹出此错误,我不知道如何解释该消息。任何人都可以描述是什

This error pops up on my JS console in the browser, and I'm not sure how to interpret the message. Can anyone describe what causes this?

谢谢

推荐答案

这意味着您必须通过以下方式声明严格模式在文件的开头写入use strict或使用块范围声明的函数。

This means that you must declare strict mode by writing "use strict" at the beginning of the file or the function to use block-scope declarations.

EX :

function test(){
    "use strict";
    let a = 1;
} 

这篇关于未捕获的SyntaxError:在严格模式之外尚不支持块范围的声明(let,const,function,class)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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