为什么在大型项目中data需要使用return返回数据呢?
答:不使用return包裹的数据会在项目的全局可见,会造成变量污染;使用return包裹后数据中变量只在当前组件中生效,不会影响其他组件。
let app= newVue({
el:"#app",
data:{
msg:''
},
methods:{
}
})
export default{
data(){
return {
showLogin:true,
// def_act: '/A_VUE',
msg: 'hello vue',
user:'',
homeContent: false,
}
},
methods:{
}
}
原文:https://www.cnblogs.com/divtab/p/10985825.html