Why does data write the return value in vue

Why write return?
Because the data that is not wrapped with return will be visible globally in the project, it will cause variable pollution. After
using the return package, the variables in the data will only take effect in the current component and will not affect other components.
Record here, there are two ways to write data attached below, remind yourself not to forget.

简单的vue实例data属性展现的形式:
let app= newVue({
    
    
    el:"#app",
    data:{
    
    
        msg:''
    }
})
使用组件化项目的形式:
export default{
    
    
    data(){
    
    
        return {
    
    
     		msg:''
        }
    }
}


Guess you like

Origin blog.csdn.net/qq_43511063/article/details/108910853