Appearance
vue/no-mutating-props
禁止组件 props 的修改
- ⚙️ 此规则包含在
"plugin:vue/essential"
、*.configs["flat/essential"]
、"plugin:vue/vue2-essential"
、*.configs["flat/vue2-essential"]
、"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"]
中。
📖 规则详情
此规则报告组件属性的修改。
¥This rule reports mutation of component props.
🔧选项
¥🔧 Options
json
{
"vue/no-mutating-props": ["error", {
"shallowOnly": false
}]
}
"shallowOnly"(
boolean
)允许改变 prop 的值但保留引用不变。默认值为false
。¥"shallowOnly" (
boolean
) Enables mutating the value of a prop but leaving the reference the same. Default isfalse
.
"shallowOnly":true
📚扩展阅读
¥📚 Further Reading
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v7.0.0 中引入
¥This rule was introduced in eslint-plugin-vue v7.0.0
🔍代码实现
¥🔍 Implementation