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

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

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

推荐文章

markdowns滚动事件
2024-11-19 10:07:32 +0800 CST
介绍Vue3的Tree Shaking是什么?
2024-11-18 20:37:41 +0800 CST
纯CSS实现3D云动画效果
2024-11-18 18:48:05 +0800 CST
Vue3中的v-bind指令有什么新特性?
2024-11-18 14:58:47 +0800 CST
Vue3中的自定义指令有哪些变化?
2024-11-18 07:48:06 +0800 CST
内网穿透技术详解与工具对比
2025-04-01 22:12:02 +0800 CST
js函数常见的写法以及调用方法
2024-11-19 08:55:17 +0800 CST
MySQL 主从同步一致性详解
2024-11-19 02:49:19 +0800 CST
如何将TypeScript与Vue3结合使用
2024-11-19 01:47:20 +0800 CST
PHP 如何输出带微秒的时间
2024-11-18 01:58:41 +0800 CST
Golang中国地址生成扩展包
2024-11-19 06:01:16 +0800 CST
PHP设计模式:单例模式
2024-11-18 18:31:43 +0800 CST
php指定版本安装php扩展
2024-11-19 04:10:55 +0800 CST
使用Rust进行跨平台GUI开发
2024-11-18 20:51:20 +0800 CST
Python Invoke:强大的自动化任务库
2024-11-18 14:05:40 +0800 CST
php 统一接受回调的方案
2024-11-19 03:21:07 +0800 CST
程序员茄子在线接单