Skip to content

API note RE: extracting the source plain data object via JSON parse/stringify #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 20, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,12 @@ type: api

The data object for the Vue instance. Vue.js will recursively convert its properties into getter/setters to make it "reactive". **The object must be plain**: native objects, existing getter/setters and prototype properties are ignored. It is not recommended to observe complex objects.

Once the instance is created, the original data object can be accessed as `vm.$data`. The Vue instance also proxies all the properties found on the data object.
Once the instance is created, the data object can be accessed as `vm.$data`. The Vue instance also proxies all the properties found on the data object.

Properties that start with `_` or `$` will **not** be proxied on the Vue instance because they may conflict with Vue's internal properties and API methods. You will have to access them as `vm.$data._property`.

If required, the original **plain** data object can be extracted by passing `vm.$data` through `JSON.parse(JSON.stringify(...))`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not really extracting the "original object" - the original object is the data object. What you get from JSON.parse(JSON.stringify()) is in fact a deep clone of the original object.


- **Example:**

``` js
Expand Down