Vue 'data' Option
Example
Using a data property inside thedata option to hold a message.
export default { data() { return { msg: 'Hello World!' }; }};Run Example »Definition and Usage
Thedata option is a function that returns an object with all the data properties inside.
The object returned by thedata function can be accessed withthis.$data, and a specific data property 'count' can be accessed withthis.$data.count, or simplythis.count.
Data properties with a name that starts with$ or_ must be accessed through thethis.$data object, they cannot be accessed otherwise.
It is possible to add new data properties after the application has started running, by usingthis.$data, but it is not recommended.
Related Pages
Vue Tutorial:Vue Introduction
Vue Reference:Vue $data Object

