Appearance
vue/order-in-components
强制组件中属性的顺序
- ⚙️ 此规则包含在
"plugin:vue/recommended"
、*.configs["flat/recommended"]
、"plugin:vue/vue2-recommended"
和*.configs["flat/vue2-recommended"]
中。
🔧命令行 上的
--fix
选项可以自动修复此规则报告的一些问题。¥🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule.💡此规则报告的某些问题可以通过编辑器 suggestions 手动修复。
¥💡 Some problems reported by this rule are manually fixable by editor suggestions.
📖 规则详情
此规则确保你保持组件中声明的属性顺序。建议的属性顺序可以是 找到这里。
¥This rule makes sure you keep declared order of properties in components. Recommended order of properties can be found here.
🔧选项
¥🔧 Options
json
{
"vue/order-in-components": ["error", {
"order": [
"el",
"name",
"key",
"parent",
"functional",
["delimiters", "comments"],
["components", "directives", "filters"],
"extends",
"mixins",
["provide", "inject"],
"ROUTER_GUARDS",
"layout",
"middleware",
"validate",
"scrollToTop",
"transition",
"loading",
"inheritAttrs",
"model",
["props", "propsData"],
"emits",
"slots",
"expose",
"setup",
"asyncData",
"data",
"fetch",
"head",
"computed",
"watch",
"watchQuery",
"LIFECYCLE_HOOKS",
"methods",
["template", "render"],
"renderError"
]
}]
}
order
((string | string[])[]
) ...属性的顺序。元素是属性名称或以下组之一:¥
order
((string | string[])[]
) ... The order of properties. Elements are the property names or one of the following groups:LIFECYCLE_HOOKS
:Vue 生命周期事件,按调用顺序排列¥
LIFECYCLE_HOOKS
: Vue Lifecycle Events, in the order they are calledROUTER_GUARDS
:Vue 路由导航守卫,按调用顺序排列¥
ROUTER_GUARDS
: Vue Router Navigation Guards, in the order they are called
如果元素是字符串数组,则意味着其中任何一个都可以无序放置在那里。默认值在上面。
¥If an element is an array of strings, it means any of those can be placed there unordered. Default is above.
📚扩展阅读
¥📚 Further Reading
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue 中引入 v3.2.0
¥This rule was introduced in eslint-plugin-vue v3.2.0
🔍代码实现
¥🔍 Implementation