vue/no-deprecated-slot-attribute
禁止使用已弃用的 slot 属性。
| 默认严重程度 | 预设 | 自动修复 | 选项 |
|---|---|---|---|
error |
essential, happy-path, nuxt, ecosystem, opinionated |
不支持 | 无 |
适用范围:Vue SFC 模板和代码块,包括规则所需的脚本上下文。
错误示例
通过旧 slot 属性选择 header 插槽。
<template>
<Foo>
<template slot="header"><h1>Title</h1></template>
<div :slot="name">Title</div>
</Foo>
</template>
正确示例
v-slot:header 使用当前指令显式选择 header 插槽。
<template>
<Foo>
<template v-slot:header><h1>Title</h1></template>
</Foo>
</template>
配置(Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/no-deprecated-slot-attribute": "error"
}
},
});
然后运行 vp run lint。