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