You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apis/optionsdata.js
+8-4Lines changed: 8 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -18,12 +18,16 @@ const DATA = {
18
18
it is not recommended to observe objects with its own stateful behavior.Once observed, you
19
19
can no longer add reactive properties to the root data object. It is therefore recommended
20
20
to declare all root-level reactive properties upfront, before creating the instance. After the
21
-
instance is created, the original data object can be accessed as ${colorArgs('vm.$data')}. The Vue instance
22
-
also proxies all the properties found on the data object, so ${colorArgs('vm.a')} will be equivalent to
23
-
${colorArgs('vm.$data.a')}. Properties that start with ${colorArgs('_')} or ${colorArgs('$')} will ${chalk.bold('not')} be proxied on the Vue instance because they may conflict
24
-
with Vue’s internal properties and API methods. You will have to access them as ${colorArgs('vm.$data._property')}.
21
+
instance is created, the original data object can be accessed as ${colorArgs('vm.$data')}.
22
+
23
+
The Vue instance also proxies all the properties found on the data object, so ${colorArgs('vm.a')} will be equivalent to
24
+
${colorArgs('vm.$data.a')}. Properties that start with ${colorArgs('_')} or ${colorArgs('$')} will ${chalk.bold('not')}
25
+
be proxied on the Vue instance because they may conflict with Vue’s internal properties and API methods.
26
+
You will have to access them as ${colorArgs('vm.$data._property')}.
27
+
25
28
When defining a ${chalk.bold('component')}, ${colorArgs('data')} must be declared as a function that returns the initial data object,
26
29
because there will be many instances created using the same definition.
30
+
27
31
If we still use a plain object for ${colorArgs('data')}, that same object will be ${chalk.bold('shared by reference')}
28
32
across all instances created! By providing a ${colorArgs('data')} function, every time a new instance is created, we can simply
29
33
call it to return a fresh copy of the initial data. If required, a deep clone of the original object can be
0 commit comments