Eslint 問題記錄及解決辦法
1 xx is never reassigned. Use 'const' instead.
原因: Eslint: 變量值未發生修改,應將修飾符改爲const,報錯消失
知識點:
let聲明的變量只在它所在的代碼塊有效
let命令所聲明的變量一定要在聲明後使用,否則報錯
var命令聲明的,在全局範圍內都有效
var命令會發生”變量提升“現象,即變量可以在聲明之前使用,值爲undefined。
const聲明一個只讀的常量。一旦聲明,常量的值就不能改變。
const聲明的變量不得改變值,這意味着,const一旦聲明變量,就必須立即初始化,不能留到以後賦值
參考:vue初始與變量聲明
2 Unnecessarily quoted property 'seatNo' found.
原因:表示 key沒必要加引號
require quotes around object literal property names (quote-props)
要求對象字面量屬性名稱使用引號
3
warning in ./src/style/common.scss
Module Warning (from ./node_modules/postcss-loader/src/index.js):
Warning
(410:1) '.is-progress::before' already has a 'content' property, give up to overwrite it.
報錯原因:
postcss-viewport-units 插件自動給每個元素添加了content
解決辦法:
配置.postcssrc.js的postcss-viewport-units:
'postcss-viewport-units': {
filterRule: rule => rule.selector.includes('::after') && rule.selector.includes('::before') && rule.selector.includes(':after') && rule.selector.includes(':before')
}