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

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

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

推荐文章

Web 端 Office 文件预览工具库
2024-11-18 22:19:16 +0800 CST
Rust async/await 异步运行时
2024-11-18 19:04:17 +0800 CST
关于 `nohup` 和 `&` 的使用说明
2024-11-19 08:49:44 +0800 CST
html文本加载动画
2024-11-19 06:24:21 +0800 CST
Nginx 状态监控与日志分析
2024-11-19 09:36:18 +0800 CST
Golang在整洁架构中优雅使用事务
2024-11-18 19:26:04 +0800 CST
pin.gl是基于WebRTC的屏幕共享工具
2024-11-19 06:38:05 +0800 CST
内网穿透技术详解与工具对比
2025-04-01 22:12:02 +0800 CST
Python中何时应该使用异常处理
2024-11-19 01:16:28 +0800 CST
动态渐变背景
2024-11-19 01:49:50 +0800 CST
Vue3 组件间通信的多种方式
2024-11-19 02:57:47 +0800 CST
WebSocket在消息推送中的应用代码
2024-11-18 21:46:05 +0800 CST
thinkphp分页扩展
2024-11-18 10:18:09 +0800 CST
程序员茄子在线接单