Appearance
vue/no-restricted-class
禁止 Vue 组件中的特定类
¥disallow specific classes in Vue components
📖 规则详情
此规则允许你指定你不想在模板中允许的类列表。
¥This rule lets you specify a list of classes that you don't want to allow in your templates.
🔧选项
¥🔧 Options
指定禁用类列表的最简单方法是直接在规则配置中传递它。
¥The simplest way to specify a list of forbidden classes is to pass it directly in the rule configuration.
json
{
"vue/no-restricted-class": ["error", "forbidden", "forbidden-two", "forbidden-three", "/^for(bidden|gotten)/"]
}
注意
此规则将仅检测模板中用作字符串的类。通过变量传递类(如下所示)不会被此规则检测到。
¥This rule will only detect classes that are used as strings in your templates. Passing classes via variables, like below, will not be detected by this rule.
vue
<template>
<div :class="classes" />
</template>
<script>
export default {
data() {
return {
classes: 'forbidden'
}
}
}
</script>
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v7.19.0 中引入
¥This rule was introduced in eslint-plugin-vue v7.19.0
🔍代码实现
¥🔍 Implementation