babel-plugin-transform-remove-strict-mode

场景:在VUE项目中,需要用到横向滚动条,在引入MUI相关的组件后,模板中的代码如下

在控制台中报错

报错内容说的是在严格模式下(strict mode)类型错误

经过推测,觉得可能是mui.js中用到了‘caller’,'callee','arguments'东西,但是,webpack打包好的bundle.js中,默认是启用严格模式的,所以,这两者冲突了

解决方案:

1.把mui.js中的非严格模式的代码改掉,但是去操作mui不现实

2.把webpack打包时候的严格模式禁用掉

  2.1在控制台安装插件

cnpm install babel-plugin-transform-remove-strict-mode -D

  2.2使用方法

如果使用的是.babelrc插入“plugins”:["transform-remove-strict-mode"]

如果使用的是CLI插入 “$ babel  --plugins  transform-remove-strict-mode  script.js”

如果使用的是Node API 则插入"require("babel-core").transform("code",{plugin:["transfomr-remove-strict-mode"]})"

打开页面拉动横向滚动条,控制台报错

解决办法:

猜你喜欢

转载自www.cnblogs.com/webenjoy/p/12080935.html