@vue/cli3中解決Elint中console.log報錯的問題


 

方法一:package.json中”eslintConfig”>"rules”字段添加如下代碼

"no-console": "off",

      "no-restricted-syntax": [

        "error",

        {

          "selector": "CallExpression[callee.object.name='console'][callee.property.name!=/^(log|warn|error|info|trace)$/]",

          "message": "Unexpected property on console object was called"

        }

      ]

 

}

 

 

 

 

 

方法二:在vue.config.js中添加lintOnSave: false關閉Elint規范

 

 

 

 

 

方法三:@vue/cli3中接除Elint中不可以用console的開關,或者用window.console.log()代替console.log()即可:

 

參考地址:https://eslint.org/docs/rules/no-console


免責聲明!

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



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