编程 解决Vue3.0报错error: Unexpected console statement (no-console)

2024-11-18 17:38:39 +0800 CST views 4050

写项目使用ESLint来遵守代码固然很重要,但是一些规范也是很蛋疼。比如今天提示如下错误

error  in ./src/pages/index.vue

Module Error (from ./node_modules/eslint-loader/index.js):
error: Unexpected console statement (no-console) at src\pages\index.vue:47:13:
  45 |             file.url = 'https://o5wwk8baw.qnssl.com/7eb99afb9d5f317c912f08b5212fd69a/avatar';
  46 |             file.name = '7eb99afb9d5f317c912f08b5212fd69a';
> 47 |             console.log(file);
     |             ^
  48 |         }
  49 |     }
  50 | }


1 error found.

#解决办法

修改package.json中的eslintConfig:{} 中的 “rules”:{},增加一行代码: "no-console":"off"

"eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "rules": {
      "no-console":"off"
    },
    "parserOptions": {
      "parser": "babel-eslint"
    }
  },

#重启服务问题解决

复制全文 生成海报 js node babel

推荐文章

js生成器函数
2024-11-18 15:21:08 +0800 CST
mysql 优化指南
2024-11-18 21:01:24 +0800 CST
赚点点任务系统
2024-11-19 02:17:29 +0800 CST
JS中 `sleep` 方法的实现
2024-11-19 08:10:32 +0800 CST
php机器学习神经网络库
2024-11-19 09:03:47 +0800 CST
一个简单的html卡片元素代码
2024-11-18 18:14:27 +0800 CST
Vue中的样式绑定是如何实现的?
2024-11-18 10:52:14 +0800 CST
Hypothesis是一个强大的Python测试库
2024-11-19 04:31:30 +0800 CST
windon安装beego框架记录
2024-11-19 09:55:33 +0800 CST
程序员茄子在线接单