【发布时间】:2021-07-21 10:04:30
【问题描述】:
我在 Vue 组件上添加了 es-lint 检查,但组件的脚本不在同一个文件中,我将它作为项目中所有组件的单独文件保存。例如,我在.eslintrc.js 中添加了vue/order-in-components 规则,如果组件脚本的钩子顺序错误,则会引发错误。
正确格式:
export default {
name: 'Address',
props: {
isNewRegistration: {
type: Boolean,
required: true
}
},
data() {
return {
test: ''
}
}
}
格式错误:
export default {
name: 'Address',
// data should come after props
data() {
return {
test: ''
}
}
props: {
isNewRegistration: {
type: Boolean,
required: true
}
}
}
组件文档中的顺序: https://eslint.vuejs.org/rules/order-in-components.html
因为我已经通过外部文件添加了组件的脚本。在我们运行 eslint --fix
对此的任何解决方案将不胜感激,在此先感谢
【问题讨论】:
标签: javascript vue.js vuejs2 eslint eslintrc