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

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

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

推荐文章

LLM驱动的强大网络爬虫工具
2024-11-19 07:37:07 +0800 CST
一些好玩且实用的开源AI工具
2024-11-19 09:31:57 +0800 CST
避免 Go 语言中的接口污染
2024-11-19 05:20:53 +0800 CST
Rust 并发执行异步操作
2024-11-18 13:32:18 +0800 CST
MySQL设置和开启慢查询
2024-11-19 03:09:43 +0800 CST
如何在Vue中处理动态路由?
2024-11-19 06:09:50 +0800 CST
JavaScript设计模式:单例模式
2024-11-18 10:57:41 +0800 CST
地图标注管理系统
2024-11-19 09:14:52 +0800 CST
H5抖音商城小黄车购物系统
2024-11-19 08:04:29 +0800 CST
三种高效获取图标资源的平台
2024-11-18 18:18:19 +0800 CST
Nginx 防盗链配置
2024-11-19 07:52:58 +0800 CST
资源文档库
2024-12-07 20:42:49 +0800 CST
`Blob` 与 `File` 的关系
2025-05-11 23:45:58 +0800 CST
前端如何一次性渲染十万条数据?
2024-11-19 05:08:27 +0800 CST
程序员茄子在线接单