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

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

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

推荐文章

7种Go语言生成唯一ID的实用方法
2024-11-19 05:22:50 +0800 CST
CSS 中的 `scrollbar-width` 属性
2024-11-19 01:32:55 +0800 CST
关于 `nohup` 和 `&` 的使用说明
2024-11-19 08:49:44 +0800 CST
Vue3中的事件处理方式有何变化?
2024-11-17 17:10:29 +0800 CST
Rust 与 sqlx:数据库迁移实战指南
2024-11-19 02:38:49 +0800 CST
PHP解决XSS攻击
2024-11-19 02:17:37 +0800 CST
Vue中如何使用API发送异步请求?
2024-11-19 10:04:27 +0800 CST
前端代码规范 - Commit 提交规范
2024-11-18 10:18:08 +0800 CST
Golang中国地址生成扩展包
2024-11-19 06:01:16 +0800 CST
Vue3中如何实现响应式数据?
2024-11-18 10:15:48 +0800 CST
api远程把word文件转换为pdf
2024-11-19 03:48:33 +0800 CST
Python Invoke:强大的自动化任务库
2024-11-18 14:05:40 +0800 CST
Golang 几种使用 Channel 的错误姿势
2024-11-19 01:42:18 +0800 CST
程序员茄子在线接单