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

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

写项目使用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中如何实现国际化(i18n)?
2024-11-19 06:35:21 +0800 CST
#免密码登录服务器
2024-11-19 04:29:52 +0800 CST
Python 微软邮箱 OAuth2 认证 Demo
2024-11-20 15:42:09 +0800 CST
H5保险购买与投诉意见
2024-11-19 03:48:35 +0800 CST
7种Go语言生成唯一ID的实用方法
2024-11-19 05:22:50 +0800 CST
Vue3结合Driver.js实现新手指引功能
2024-11-19 08:46:50 +0800 CST
php 统一接受回调的方案
2024-11-19 03:21:07 +0800 CST
IP地址获取函数
2024-11-19 00:03:29 +0800 CST
Web浏览器的定时器问题思考
2024-11-18 22:19:55 +0800 CST
api接口怎么对接
2024-11-19 09:42:47 +0800 CST
Vue3中的v-bind指令有什么新特性?
2024-11-18 14:58:47 +0800 CST
百度开源压测工具 dperf
2024-11-18 16:50:58 +0800 CST
PHP 压缩包脚本功能说明
2024-11-19 03:35:29 +0800 CST
PHP 代码功能与使用说明
2024-11-18 23:08:44 +0800 CST
thinkphp swoole websocket 结合的demo
2024-11-18 10:18:17 +0800 CST
【SQL注入】关于GORM的SQL注入问题
2024-11-19 06:54:57 +0800 CST
Rust 并发执行异步操作
2024-11-18 13:32:18 +0800 CST
linux设置开机自启动
2024-11-17 05:09:12 +0800 CST
25个实用的JavaScript单行代码片段
2024-11-18 04:59:49 +0800 CST
程序员茄子在线接单