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

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

写项目使用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

推荐文章

Go 单元测试
2024-11-18 19:21:56 +0800 CST
Nginx 反向代理 Redis 服务
2024-11-19 09:41:21 +0800 CST
html一个包含iPhoneX和MacBook模拟器
2024-11-19 08:03:47 +0800 CST
php curl并发代码
2024-11-18 01:45:03 +0800 CST
支付轮询打赏系统介绍
2024-11-18 16:40:31 +0800 CST
php使用文件锁解决少量并发问题
2024-11-17 05:07:57 +0800 CST
PHP openssl 生成公私钥匙
2024-11-17 05:00:37 +0800 CST
PHP解决XSS攻击
2024-11-19 02:17:37 +0800 CST
MySQL用命令行复制表的方法
2024-11-17 05:03:46 +0800 CST
php指定版本安装php扩展
2024-11-19 04:10:55 +0800 CST
Nginx 反向代理
2024-11-19 08:02:10 +0800 CST
Plyr.js 播放器介绍
2024-11-18 12:39:35 +0800 CST
在 Nginx 中保存并记录 POST 数据
2024-11-19 06:54:06 +0800 CST
38个实用的JavaScript技巧
2024-11-19 07:42:44 +0800 CST
使用Python实现邮件自动化
2024-11-18 20:18:14 +0800 CST
程序员茄子在线接单