Skip to content

vue/no-shared-component-data ​

强制组件的数据属性为函数

  • ⚙️ 此规则包含在 "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"] 中。
  • 🔧命令行 上的 --fix 选项可以自动修复此规则报告的一些问题。

    ¥🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

在组件上使用数据属性时(即除 new Vue 之外的任何地方),值必须是返回对象的函数。

¥When using the data property on a component (i.e. anywhere except on new Vue), the value must be a function that returns an object.

📖 规则详情 ​

当 data 的值是对象时,它在组件的所有实例之间共享。

¥When the value of data is an object, it’s shared across all instances of a component.

Now loading...
Now loading...

🔧选项 ​

¥🔧 Options

无。

¥Nothing.

📚扩展阅读 ​

¥📚 Further Reading

🚀版本 ​

¥🚀 Version

此规则在 eslint-plugin-vue v3.8.0 中引入

¥This rule was introduced in eslint-plugin-vue v3.8.0

🔍代码实现 ​

¥🔍 Implementation

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