el与data的两种写法
el
第一种写法:new的时候指定el,el:’#root’
第二种写法:v.$mount(’#root’)
data
第一种写法:对象式
data:{
name:‘xxx’
}
第二种写法:函数式,data普通函数中的this是Vue对象,箭头函数this是全局window,组件必须用函数式不然会报错,vue管理的函数一定不要写箭头函数
data:function(){
return{
name:‘xxx’
}
}
data(){
return{
name:‘xxx’
}
}