参考地址:http://www.gold404.cn/info/87
导致这个报错的原因就是eslint校验,
就是你当初在vue创建脚手架的时候选择了eslint校验;
后面你绝对会碰到这样的报错,毋庸置疑。
而这个报错信息也很简单,就是你定义了某个变量,但是你没有使用它。
eslint规范就是你要么不定义,要么定义了就一定得用,就像那个啥,你必须得负责任

下面说说怎么一劳永逸的解决这个报错吧。如果你是使用vue-clii3以上版本,打开你的.eslintrc.js文件,在rule中添加:
.eslintrc.js文件 module.exports = {
root: true,
parserOptions: {
sourceType: 'module'
},
parser: "vue-eslint-parser",
env: {
browser: true,
node: true,
es6: true,
},
rules: {
'no-console': 'off',
'no-unused-vars':'off'//意思就是不让eslint校验我定义有没有用了。
}
} 如果你没有这个文件 创建这样的文件即可。
这样你就可以解决这个问题了
eslint简介
eslint是用来管理和检测js代码风格的工具,可以和编辑器搭配使用,如vscode的eslint插件 当有不符合配置文件内容的代码出现就会报错或者警告
// http://eslint.org/docs/user-guide/configuring

module.exports = {
//此项是用来告诉eslint找当前配置文件不能往父级查找
root: true,
//此项是用来指定eslint解析器的,解析器必须符合规则,babel-eslint解析器是对babel解析器的包装使其与ESLint解析
parser: 'babel-eslint',
//此项是用来指定javaScript语言类型和风格,sourceType用来指定js导入的方式,默认是script,此处设置为module,指某块导入方式
parserOptions: {
sourceType: 'module'
},
//此项指定环境的全局变量,下面的配置指定为浏览器环境
env: {
browser: true,
},
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
// 此项是用来配置标准的js风格,就是说写代码的时候要规范的写,如果你使用vs-code我觉得应该可以避免出错
extends: 'standard',
// required to lint *.vue files
// 此项是用来提供插件的,插件名称省略了eslint-plugin-,下面这个配置是用来规范html的
plugins: [
'html'
],
// add your custom rules here
// 下面这些rules是用来设置从插件来的规范代码的规则,使用必须去掉前缀eslint-plugin-
// 主要有如下的设置规则,可以设置字符串也可以设置数字,两者效果一致
// "off" -> 0 关闭规则
// "warn" -> 1 开启警告规则
//"error" -> 2 开启错误规则
// 了解了上面这些,下面这些代码相信也看的明白了
'rules': {
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
}
}
如果你的团队不是特别的大,
或者你对eslint不是特别的熟悉,
个人不建议你在创建脚手架的安装eslint,因为后期可能会非常的麻烦哈,真的是非常的麻烦; "eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
这两个插件删除了

vue报错:'XX' is defined but never used no-unused-vars的更多相关文章

  1. Feign报错'xx.FeignClientSpecification', defined in null, could not be registered.

    解决: 在application.yml中配置: spring: main: allow-bean-definition-overriding: true 参考:https://blog.csdn.n ...

  2. Vue报错 type check failed for prop “xxx“. Expected String with value “xx“,got Number with value ‘xx‘

    vue报错    [Vue warn]: Invalid prop: type check failed for prop "name". Expected String with ...

  3. Vue 报错Error in render: “TypeError: Cannot read properties of null (reading ‘xxx’)” found in

    前端vue报错 [Vue warn]: Error in render: "TypeError: Cannot read properties of null (reading 'name' ...

  4. 关于IONIC 报错 XX is not a function

    刚开始 做一个项目,总是报错"XX is not  a function"   最后发现 原因 ,   原来是 服务的 注入位置 有问题. angular.module(" ...

  5. Vue报错——“Trailing spaces not allowed”

    在VSCode中开发Vue 报错:“Trailing spaces not allowed” 这是空格多了,删除多余的空格就可以了

  6. vs中正常IIS发布网站后css样式、图片丢失jQuery报错 $ is not defined

    问题描述: VS运行能够正常看到样式和图片 ,IIS发布后样式丢失.图片不显示.并且jQuery报错“$ is not defined”. 问题分析: 1.首先怀疑是样式文件.图片等发布的时候没有发布 ...

  7. vue 报错 :属性undefined(页面成功渲染)

    vue 报错:Cannot read property 'instrumentId' of undefined" 相关代码如下: <template> ... <span& ...

  8. Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol')

    Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol') 报错信 ...

  9. vue报错信息

    1.Property or method "xxx" is not defined on the instance but referenced during render. 原因 ...

  10. vue报错Error in render: "TypeError: Cannot read property '0' of undefined"

    通常有两种情况: 1.在模板的html标签上使用length报错 vue 中使用 length判断的时候,有时会报错,如下: <div class="item_list" v ...

随机推荐

  1. VUE3/TS/TSX入门手册指北

    VUE3入门手册 vue3入门 首先 查看 官方文档:https://cn.vuejs.org/guide/quick-start.html 如果有vue2基础,速成课程:https://www.zh ...

  2. vue2升级vue3:webpack vue-loader 打包配置

    如果没有啥特别的需求还是推荐vue-cli! vite  vue3 TSX项目 虽然vite 很香,但是vite  rollup 动态加载,多页面 等问题比较难搞 vite的缺点 wepback  _ ...

  3. PPT 客户提案PPT应该怎么样改

    PPT 客户提案PPT应该怎么样改

  4. Android gradle dependency tree change(依赖树变化)监控实现,sdk version 变化一目了然

    @ 目录 前言 基本原理 执行流程 diff 报告 不同分支 merge 过来的 diff 报告 同个分支产生的 merge 报告 同个分支提交的 diff 报告 具体实现原理 我们需要监控怎样的 D ...

  5. Redis系列:使用 Redis Module 扩展功能

    ★ Redis24篇集合 1 啥是Redis Module Redis Module是Redis的一种扩展模块,从 4.0版本开始,允许用户自定义扩展模块,在Redis内部实现新的数据类型和功能,使用 ...

  6. Codeforces Round #716 (Div. 2) A ~ D 个人题解

    补题链接:Here 1514A. Perfectly Imperfect Array 题意:给定长度为 \(n\) 的 \(a\) 序列,请问是否存在子序列积不存在平方根 思路:子序列的话,一个元素也 ...

  7. c#.net 6 实现简单爬虫几行代码实现百度搜索

    使用selenium封装的简单使用工具包 Gitee:SeleniumUtil: Selenium简化工具包,包含三个主流浏览器的一些基本操作 (gitee.com) 第一步安装爬虫工具: 在程序包管 ...

  8. 单元测试中如何Mock HttpContext

    最近团队有小伙伴问在单元测试中如何Mock HttpContext. 这是一个好问题,整理了一个实现方案分享给大家. 在C#中,尤其是在单元测试场景下,模拟(Mocking)HttpContext 是 ...

  9. [转帖]Linux下非oracle用户如何使用系统认证方式登陆数据

    https://www.cnblogs.com/kerrycode/p/17772866.html Linux系统中,DBA一般使用oracle用户登陆/访问Linux操作系统,然后使用sqlplus ...

  10. 使用Grafana 监控 minio 的部分改进

    使用Grafana 监控 minio 的部分改进 部署minio开启监控metrics的脚本 mkdir -p /data/minio/data cat << EOF > /etc/ ...