Appearance
vue/block-order
强制组件顶层元素的顺序
- ⚙️ 此规则包含在
"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.
📖 规则详情
此规则警告顶层标签的顺序,例如 <script>
、<template>
和 <style>
。
¥This rule warns about the order of the top-level tags, such as <script>
, <template>
& <style>
.
🔧选项
¥🔧 Options
json
{
"vue/block-order": ["error", {
"order": [ [ "script", "template" ], "style" ]
}]
}
order
((string|string[])[]
) ...顶层元素名称的顺序。默认[ [ "script", "template" ], "style" ]
。也可能是 CSS 选择器,例如script[setup]
和i18n:not([locale=en])
。¥
order
((string|string[])[]
) ... The order of top-level element names. default[ [ "script", "template" ], "style" ]
. May also be CSS selectors, such asscript[setup]
andi18n:not([locale=en])
.
{ "order": [ [ "script", "template" ], "style" ] }
(默认)
¥{ "order": [ [ "script", "template" ], "style" ] }
(default)
{ "order": ["template", "script", "style"] }
{ "order": ["docs", "template", "script", "style"] }
{ 'order': ['template', 'script:not([setup])', 'script[setup]'] }
{ 'order': ['template', 'style:not([scoped])', 'style[scoped]'] }
{ 'order': ['template', 'i18n:not([locale=en])', 'i18n[locale=en]'] }
📚扩展阅读
¥📚 Further Reading
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v9.16.0 中引入
¥This rule was introduced in eslint-plugin-vue v9.16.0
🔍代码实现
¥🔍 Implementation