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

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

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

推荐文章

Vue3如何执行响应式数据绑定?
2024-11-18 12:31:22 +0800 CST
html一份退出酒场的告知书
2024-11-18 18:14:45 +0800 CST
Vue3中如何处理异步操作?
2024-11-19 04:06:07 +0800 CST
MySQL死锁 - 更新插入导致死锁
2024-11-19 05:53:50 +0800 CST
Vue3中如何进行性能优化?
2024-11-17 22:52:59 +0800 CST
一键配置本地yum源
2024-11-18 14:45:15 +0800 CST
使用xshell上传和下载文件
2024-11-18 12:55:11 +0800 CST
LLM驱动的强大网络爬虫工具
2024-11-19 07:37:07 +0800 CST
MyLib5,一个Python中非常有用的库
2024-11-18 12:50:13 +0800 CST
JavaScript设计模式:发布订阅模式
2024-11-18 01:52:39 +0800 CST
Vue3中如何处理组件的单元测试?
2024-11-18 15:00:45 +0800 CST
MySQL设置和开启慢查询
2024-11-19 03:09:43 +0800 CST
推荐几个前端常用的工具网站
2024-11-19 07:58:08 +0800 CST
PHP openssl 生成公私钥匙
2024-11-17 05:00:37 +0800 CST
程序员茄子在线接单