Appearance
vue/component-api-style
强制组件 API 样式
¥enforce component API style
📖 规则详情
此规则旨在使你在项目中定义 Vue 组件时使用的 API 样式保持一致。
¥This rule aims to make the API style you use to define Vue components consistent in your project.
例如,如果你只想允许 <script setup>
和 Composition API。(这是此规则的默认设置。)
¥For example, if you want to allow only <script setup>
and Composition API.\ (This is the default for this rule.)
🔧选项
¥🔧 Options
json
{
"vue/component-api-style": ["error",
["script-setup", "composition"] // "script-setup", "composition", "composition-vue2", or "options"
]
}
数组选项...定义你要允许的 API 样式。默认值为
["script-setup", "composition"]
。你可以使用以下值。¥Array options ... Defines the API styles you want to allow. Default is
["script-setup", "composition"]
. You can use the following values."script-setup"
...如果设置,则允许<script setup>
。¥
"script-setup"
... If set, allows<script setup>
."composition"
...如果设置,则允许 组合 API(不是<script setup>
)。¥
"composition"
... If set, allows Composition API (not<script setup>
)."composition-vue2"
...如果设置,则允许 Vue 2 的组合 API(不是<script setup>
)。特别是,它允许render
、renderTracked
和renderTriggered
与setup
一起使用。¥
"composition-vue2"
... If set, allows Composition API for Vue 2 (not<script setup>
). In particular, it allowsrender
,renderTracked
andrenderTriggered
alongsidesetup
."options"
...如果设置,则允许选项 API。¥
"options"
... If set, allows Options API.
["options"]
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v7.18.0 中引入
¥This rule was introduced in eslint-plugin-vue v7.18.0
🔍代码实现
¥🔍 Implementation