cordova打包APK,SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported ...

javascript 严格模式

第一次接触let关键字,有一个要非常非常要注意的概念就是”javascript 严格模式”,比如下述的代码运行就会报错:

let hello = 'hello world.';
console.log(hello);

错误信息如下:

let hello = 'hello world.';
^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    ...

解决方法就是,在文件头添加”javascript 严格模式”声明:

'use strict';

let hello = 'hello world.';
console.log(hello);

更多更详细的关于”javascript 严格模式”说明,请参考阮一峰的博客 
《Javascript 严格模式详解》

转载于:https://www.cnblogs.com/lydiawork/p/7808542.html

你可能感兴趣的:(cordova打包APK,SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported ...)