Using Babel-Standalone ,我正在尝试禁用 use strict
,以便我可以使用已弃用的 with
语句 the es2015 preset reference 。
var code = "with (p) { // do something }";
var output = Babel.transform(code, { presets: [['es2015', {"loose": true}]] }).code;
这给了我这个错误:
babel.js:17955 Uncaught SyntaxError: unknown: 'with' in strict mode (1:5)
如何使用 Babel Standalone 禁用严格模式?
最佳答案
答案是 parserOpts
属性,它对应于 options.js在 Babylon
var output = Babel.transform(code,
{
presets: ['es2015'],
parserOpts: { strictMode: false }
});
关于babeljs - 在 babel-standalone 中禁用 "use strict",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41944982/