vue/no-multiple-slot-args Restriction
它是做什么的
禁止向具名作用域插槽传递多个参数。
为什么这不好?
用户必须按固定顺序使用这些参数,且不能省略不需要的参数。 例如,如果某个插槽传入了 5 个参数,但用户实际上只需要最后 2 个, 他们就必须声明全部 5 个参数,才能使用最后 2 个。
更多信息可见 vuejs/vue#9468
示例
以下是此规则的错误代码示例:
vue
<script>
export default {
render(h) {
var children = this.$scopedSlots.default(foo, bar);
var children = this.$scopedSlots.default(...foo);
},
};
</script>以下是此规则的正确代码示例:
vue
<script>
export default {
render(h) {
var children = this.$scopedSlots.default();
var children = this.$scopedSlots.default(foo);
var children = this.$scopedSlots.default({ foo, bar });
},
};
</script>如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["vue"],
"rules": {
"vue/no-multiple-slot-args": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["vue"],
rules: {
"vue/no-multiple-slot-args": "error",
},
});bash
oxlint --deny vue/no-multiple-slot-args --vue-plugin版本
此规则于 v1.15.0 中添加。
