In the Vue instance seen in a simple vue instance, the data attribute is shown in the following way:
let app= newVue({ el:"#app", data:{ msg:'' }, methods:{ } })
In projects that use componentization, the following form is used:
export default{ data(){ return { showLogin:true, // def_act: '/A_VUE', msg: 'hello vue', user:'', homeContent: false, } }, methods:{ } }
Why does data need to use return to return data in large projects?
say:Data wrapped without return will be visible globally in the project and will cause variable contamination.
After wrapping with return, variables in the data will only take effect in the current component and will not affect other components.
In the above vue example, the method of data using return package is all the content I share with you. I hope you can give you a reference and I hope you support me more.