Skip to content

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 as script[setup] and i18n:not([locale=en]).

{ "order": [ [ "script", "template" ], "style" ] }(默认) ​

¥{ "order": [ [ "script", "template" ], "style" ] } (default)

Now loading...
Now loading...
Now loading...

{ "order": ["template", "script", "style"] } ​

Now loading...
Now loading...

{ "order": ["docs", "template", "script", "style"] } ​

Now loading...
Now loading...

{ 'order': ['template', 'script:not([setup])', 'script[setup]'] } ​

Now loading...
Now loading...

{ 'order': ['template', 'style:not([scoped])', 'style[scoped]'] } ​

Now loading...
Now loading...

{ 'order': ['template', 'i18n:not([locale=en])', 'i18n[locale=en]'] } ​

Now loading...
Now loading...

📚扩展阅读 ​

¥📚 Further Reading

🚀版本 ​

¥🚀 Version

此规则在 eslint-plugin-vue v9.16.0 中引入

¥This rule was introduced in eslint-plugin-vue v9.16.0

🔍代码实现 ​

¥🔍 Implementation

eslint-plugin-vue v10.4 中文网 - 粤ICP备13048890号