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

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

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

推荐文章

开发外贸客户的推荐网站
2024-11-17 04:44:05 +0800 CST
Requests库详细介绍
2024-11-18 05:53:37 +0800 CST
FastAPI 入门指南
2024-11-19 08:51:54 +0800 CST
三种高效获取图标资源的平台
2024-11-18 18:18:19 +0800 CST
网站日志分析脚本
2024-11-19 03:48:35 +0800 CST
网络数据抓取神器 Pipet
2024-11-19 05:43:20 +0800 CST
聚合支付管理系统
2025-07-23 13:33:30 +0800 CST
黑客帝国代码雨效果
2024-11-19 01:49:31 +0800 CST
如何在Vue3中处理全局状态管理?
2024-11-18 19:25:59 +0800 CST
2025,重新认识 HTML!
2025-02-07 14:40:00 +0800 CST
智能视频墙
2025-02-22 11:21:29 +0800 CST
Vue 3 中的 Watch 实现及最佳实践
2024-11-18 22:18:40 +0800 CST
Hypothesis是一个强大的Python测试库
2024-11-19 04:31:30 +0800 CST
介绍Vue3的Tree Shaking是什么?
2024-11-18 20:37:41 +0800 CST
企业官网案例-芊诺网络科技官网
2024-11-18 11:30:20 +0800 CST
mysql 优化指南
2024-11-18 21:01:24 +0800 CST
deepcopy一个Go语言的深拷贝工具库
2024-11-18 18:17:40 +0800 CST
程序员茄子在线接单