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

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

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

推荐文章

PHP服务器直传阿里云OSS
2024-11-18 19:04:44 +0800 CST
2024年公司官方网站建设费用解析
2024-11-18 20:21:19 +0800 CST
在 Nginx 中保存并记录 POST 数据
2024-11-19 06:54:06 +0800 CST
JavaScript 策略模式
2024-11-19 07:34:29 +0800 CST
Python 微软邮箱 OAuth2 认证 Demo
2024-11-20 15:42:09 +0800 CST
使用Rust进行跨平台GUI开发
2024-11-18 20:51:20 +0800 CST
18个实用的 JavaScript 函数
2024-11-17 18:10:35 +0800 CST
filecmp,一个Python中非常有用的库
2024-11-19 03:23:11 +0800 CST
关于 `nohup` 和 `&` 的使用说明
2024-11-19 08:49:44 +0800 CST
最全面的 `history` 命令指南
2024-11-18 21:32:45 +0800 CST
Elasticsearch 监控和警报
2024-11-19 10:02:29 +0800 CST
Vue3中怎样处理组件引用?
2024-11-18 23:17:15 +0800 CST
12 个精选 MCP 网站推荐
2025-06-10 13:26:28 +0800 CST
页面不存在404
2024-11-19 02:13:01 +0800 CST
Python 获取网络时间和本地时间
2024-11-18 21:53:35 +0800 CST
Golang在整洁架构中优雅使用事务
2024-11-18 19:26:04 +0800 CST
php strpos查找字符串性能对比
2024-11-19 08:15:16 +0800 CST
程序员茄子在线接单