一、 问题出现:在之前进行 vue 项目开发的时候遇到了这样的异常,TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them,异常如下图所示:

二、问题分析及解决:这个异常说明了用到了'caller', 'callee', and 'arguments'东西,但是, webpack 打包好的 bundle.js 中,默认是启用严格模式的,所以,这两者冲突了。对此,我们的办法可以是把 webpack 打包时候的严格模式禁用掉,移除严格模式。对于移除严格模式,可以使用 babel-plugin-transform-remove-strict-mode 插件,进行移除。
- 第一步:
使用 npm install babel-plugin-transform-remove-strict-mode命令进行下载babel-plugin-transform-remove-strict-mode这个插件 - 第二步: 在 项目的
.babelrc文件中,引入transform-remove-strict-mode,代码如下所示:
"plugins": ["transform-remove-strict-mode"]
8888

被折叠的 条评论
为什么被折叠?



