The introduction
Vue component data (vUE component data)
data() {
return{}}Copy the code
But why is it a function that returns an object? Why not?
data : {
}
Copy the code
conclusion
- In VUE, data can be written as an object, but this is to ensure that the component is not reused
- Because of the reuse of marshals, multiple vUE instances are actually created. If data is still a single object, then all created instances keep references to the same object.
- So we return a new, brand new data object through a function execution.