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

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

写项目使用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-19 01:48:20 +0800 CST
Elasticsearch 监控和警报
2024-11-19 10:02:29 +0800 CST
Web浏览器的定时器问题思考
2024-11-18 22:19:55 +0800 CST
从Go开发者的视角看Rust
2024-11-18 11:49:49 +0800 CST
Python上下文管理器:with语句
2024-11-19 06:25:31 +0800 CST
Vue 3 路由守卫详解与实战
2024-11-17 04:39:17 +0800 CST
Vue3中如何处理状态管理?
2024-11-17 07:13:45 +0800 CST
JavaScript 异步编程入门
2024-11-19 07:07:43 +0800 CST
手机导航效果
2024-11-19 07:53:16 +0800 CST
阿里云发送短信php
2025-06-16 20:36:07 +0800 CST
JavaScript 策略模式
2024-11-19 07:34:29 +0800 CST
程序员茄子在线接单