vue-cli解除嚴格模式


我導入了js的文件時,控制台報錯
Uncaught TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
 
錯誤原因:是js文件用到了 'caller', 'callee', and 'arguments' ,但是webpack打包好build.js,默認啟用嚴格模式,所以沖突了
解決方案:
把webpack打包時候的嚴格模式禁用
這里我用vue-cli生成的項目
基本步驟

一: 下載安裝包

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

二:把.babelrc中的配置為

  .babelrc 文件添加配置

  {
  "plugins": ["transform-remove-strict-mode"]
  }

npm run dev

此時,我程序報錯了(一個奇怪的錯誤)

WARNING Compiled with 1 warnings 2:19:38 PM
warning in ./src/components/photos/PhotoList.vue

32:0-3 "export 'default' (imported as 'mui') was not found in '../../assets/dist/js/mui.min.js'

研究了一下

三:把.babelrcl里面plugins的"transform-runtime"刪除

  這時候就可以了!(這是為什么呢,等待解惑)

(問題基本搞定 下面是我引用滑動文件js的報錯解決)

 

 

 

 

 

 

 

 

四:js我這里與引用滑動有關系

我運行時控制台還是有報錯

滑動時候警告:Unable to preventDefault inside passive event listener

在你引用滑動地方在css樣式中加

touch-action: none;
或者在css樣式中加
*{
touch-action: pan-y;
}
就好了
(這是為什么呢?我不太明白,這個等待解答)
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM