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

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

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

推荐文章

JavaScript 实现访问本地文件夹
2024-11-18 23:12:47 +0800 CST
mysql 计算附近的人
2024-11-18 13:51:11 +0800 CST
如何开发易支付插件功能
2024-11-19 08:36:25 +0800 CST
Nginx 负载均衡
2024-11-19 10:03:14 +0800 CST
在Vue3中实现代码分割和懒加载
2024-11-17 06:18:00 +0800 CST
Vue3中的虚拟滚动有哪些改进?
2024-11-18 23:58:18 +0800 CST
一键配置本地yum源
2024-11-18 14:45:15 +0800 CST
25个实用的JavaScript单行代码片段
2024-11-18 04:59:49 +0800 CST
免费常用API接口分享
2024-11-19 09:25:07 +0800 CST
MySQL 日志详解
2024-11-19 02:17:30 +0800 CST
使用 node-ssh 实现自动化部署
2024-11-18 20:06:21 +0800 CST
html一个全屏背景视频
2024-11-18 00:48:20 +0800 CST
如何在Vue3中处理全局状态管理?
2024-11-18 19:25:59 +0800 CST
FastAPI 入门指南
2024-11-19 08:51:54 +0800 CST
回到上次阅读位置技术实践
2025-04-19 09:47:31 +0800 CST
程序员茄子在线接单