Data function
Reports a Vue component data property that is not a function. Suggests wrapping an object literal with a function.
When defining a component, data
must be declared as a function that returns the initial data object, because the same definition will be used for creating numerous instances. If a plain object is still used for data
, that very object will be shared by reference across all instances created! With a data
function, every time a new instance is created we can simply call it to return a fresh copy of the initial data.
Inspection Details | |
---|---|
Available in: | CLion 2023.3, IntelliJ IDEA 2023.3, JetBrains Rider 2023.1, PhpStorm 2023.3, PyCharm 2023.3, Qodana for .NET 2023.1, Qodana for JS 2023.3, Qodana for JVM 2023.3, Qodana for PHP 2023.3, Qodana for Ruby 2023.3, RubyMine 2023.3, WebStorm 2023.3 |
Plugin: | Vue.js, 233.SNAPSHOT |