vue bug
1.报错信息
warning Unexpected var, use let or const instead no-var
warning Unexpected var, use let or const instead no-var
原因
除了非 ES6 环境外,那些现有 Javascript 项目开始在他们的代码库中引入 ES6 的,如果从 var 迁移到 let 代价高的话,可能并不适用于此规则。
解决方案
在报错信息上方会告诉你那个文件报错
这个是vue的eslint报的错 因为上述文件中同时使用了es6 es5的声明方式
2.报错信息
error Expected ‘=’ and instead saw '’ eqeqeq
原因
原因是因为’==‘和’!='会强制进行类型转换
解决
在vue项目中.eslintrc.js文件添加
rules: {
eqeqeq: ‘off’,
}
3.报错信息
error ‘div’ is never reassigned. Use ‘const’ instead prefer-const
error ‘svg’ is never reassigned. Use ‘const’ instead prefer-const
原因
在vue项目中.eslintrc.js文件添加
rules: {
‘vue/no-unused-components’: [‘off’, { ignoreWhenBindingPresent: true }],
‘prefer-const’: ‘off’,
}
4.报错信息
Syntax Error: ValidationError: Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.options has an unknown property ‘plugins’.“These properties are yalid: object ( postcssOptions?, execute?, sourcellap?, implementation?)
原因
PostCSS Loader引起
需要建立postcss.config.js
module.exports={
plugins: [
// 把px单位换算成rem单位
require(“postcss-pxtorem”)({
// 换算的基数 375的设计稿,换算基数就是37.5
rootValue: 37.5,
selectorBlackList: [”.van"],// 要忽略的选择器并保留为px。
propList: ["*"], //可以从px更改为rem的属性。
minPixelValue: 1 // 设置要替换的最小像素值。
})
]
}