gpt4 book ai didi

javascript - 带有 ES2015 babel 预设的 Marionette 不起作用

转载 作者:行者123 更新时间:2023-12-03 08:04:41 25 4
gpt4 key购买 nike

我正在使用带有 babel-loader 的 Webpack,预设了 es2015,并且我看到了这个问题:当包含 Marionette (v.2.4.3) es2015 预设更改时/lib/core/backbone.marionette.js:26 中的这个 参数改为 undefined 而不是 this。但是这个参数采用 root 变量( line 10 ),他看到什么参数是 undefined (不是 this )并输出错误。

我明白了,es2015中的预设包括babel-plugin-transform-es2015-modules-commonjs,什么包括babel-plugin-transform-strict- mode,响应严格模式并关闭 es6 模块。

我尝试修改 es2015 插件,将 require("babel-plugin-transform-es2015-modules-commonjs") 更改为 [require("babel -plugin-transform-es2015-modules-commonjs"), {"strict": false}],但这一步并不能帮助我解决问题。

谁知道,这个问题是 Marionette 的问题,或者是 babel-loader 中预设的 es2015 的问题,或者是我的问题,以及如何修复它?

最佳答案

我解决了我的问题。我的解决方案是允许在 module-commonjs 中进行顶级操作。

在 babel-preset-es2015 中将 require("babel-plugin-transform-es2015-modules-commonjs") 更改为 [require("babel-插件-transform-es2015-modules-commonjs"), {allowTopLevelThis: true }]

关于javascript - 带有 ES2015 babel 预设的 Marionette 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34436359/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com