Skip to content

vue/no-restricted-props

禁止特定 props

  • 💡 此规则报告的某些问题可由编辑器 suggestions 手动修复。

📖 规则详情

此规则允许你指定你不想在应用中使用的 props。

¥This rule allows you to specify props that you don't want to use in your application.

🔧选项

¥🔧 Options

此规则采用字符串列表,其中每个字符串都是要限制的 prop 名称或模式:

¥This rule takes a list of strings, where each string is a prop name or pattern to be restricted:

json
{
  "vue/no-restricted-props": ["error", "value", "/^forbidden/"]
}
Now loading...
Now loading...

或者,该规则也接受对象。

¥Alternatively, the rule also accepts objects.

json
{
  "vue/no-restricted-props": ["error",
    {
      "name": "value",
      "message": "If you intend a prop for v-model, it should be 'modelValue' in Vue 3.",
      "suggest": "modelValue"
    },
  ]
}

可以为对象指定以下属性。

¥The following properties can be specified for the object.

  • name ...指定 prop 名称或模式。

    ¥name ... Specify the prop name or pattern.

  • message ...指定可选的自定义消息。

    ¥message ... Specify an optional custom message.

  • suggest ...指定可选名称以建议更改。

    ¥suggest ... Specify an optional name to suggest changes.

Now loading...

🚀版本

¥🚀 Version

此规则在 eslint-plugin-vue v7.3.0 中引入

¥This rule was introduced in eslint-plugin-vue v7.3.0

🔍代码实现

¥🔍 Implementation

eslint-plugin-vue v10.0 中文网 - 粤ICP备13048890号