Skip to content

vue/prop-name-casing ​

强制 Vue 组件中 Prop 名称使用特定大小写

  • ⚙️ 此规则包含在 "plugin:vue/strongly-recommended"、*.configs["flat/strongly-recommended"]、"plugin:vue/vue2-strongly-recommended"、*.configs["flat/vue2-strongly-recommended"]、"plugin:vue/recommended"、*.configs["flat/recommended"]、"plugin:vue/vue2-recommended" 和 *.configs["flat/vue2-recommended"] 中。

📖 规则详情 ​

此规则强制在 vue 组件中正确使用 props 的大小写(camelCase)。

¥This rule enforce proper casing of props in vue components(camelCase).

Now loading...

🔧选项 ​

¥🔧 Options

json
{
  "vue/prop-name-casing": ["error",
    "camelCase" | "snake_case",
    {
      "ignoreProps": []
    }
  ]
}
  • "camelCase"(默认)...强制 props 中的属性名称为驼峰式大小写。

    ¥"camelCase" (default) ... Enforce property names in props to camel case.

  • "snake_case" ...强制 props 中的属性名称为蛇形大小写。

    ¥"snake_case" ... Enforce property names in props to snake case.

  • ignoreProps (string[]) ...不需要遵循指定大小写的 prop 名称(或模式)数组。

    ¥ignoreProps (string[]) ... An array of prop names (or patterns) that don't need to follow the specified casing.

"snake_case" ​

Now loading...

"ignoreProps": ["foo-bar", "/^_[a-z]+/u"] ​

Now loading...

👫相关规则 ​

¥👫 Related Rules

📚扩展阅读 ​

¥📚 Further Reading

🚀版本 ​

¥🚀 Version

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

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

🔍代码实现 ​

¥🔍 Implementation

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