Skip to content

vue/no-restricted-custom-event

禁止特定自定义事件

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

📖 规则详情

此规则允许你指定你不想在应用中使用的自定义事件。

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

🔧选项

¥🔧 Options

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

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

json
{
  "vue/no-restricted-custom-event": ["error", "input", "/^forbidden/"]
}
Now loading...

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

¥Alternatively, the rule also accepts objects.

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

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

¥The following properties can be specified for the object.

  • event ...指定事件名称或模式。

    ¥event ... Specify the event 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号