vue-cli创建的项目中引入第三方库报错 'caller', 'calle', and 'arguments' properties may not be

在项目中任意一处引入mui.min.js报如下错误:

Uncaught TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
    at Function.d.extend (mui.min.js?9ccf:7)
    at eval (mui.min.js?9ccf:7)
    at eval (mui.min.js?9ccf:7)
    at Object../src/lib/dist/js/mui.min.js (app.js:2074)
    at __webpack_require__ (app.js:679)
    at fn (app.js:89)
    at eval (selector.js?type=script&index=0!./src/components/photoList.vue:1)
    at Object../node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/photoList.vue (app.js:899)
    at __webpack_require__ (app.js:679)
    at fn (app.js:89)

原因:babel在将js文件转码为ES5时,默认使用严格模式,而在严格模式下,为了安全起见是不能用caller,callee,arguments等属性的。

解决方式如下:

分别在.babelrc文件和.eslintignore文件添加如下规则:

【.babelrc文件,在“plugins”:[]后添加】
"ignore": [
    "src/lib/dist/js/mui.min.js"
  ]

【.eslintignore文件添加】
src/lib/dist/js/mui.min.js

此处的路径指的是mui.min.js文件所在的相对路径,如果路径写错还是会报错,所以得注意这个路径的正确与否。如果不知道怎么确定这个路径,可以这样做:

在mui.min.js文件上点击右键,选择copy relative path,然后直接把这个路径复制到两个文件中去,之后就一切正常了。如图:
在这里插入图片描述

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值