1.el有2种写法
(1).先new Vue时配置el属性
举例:
new Vue{
el:'#root'
}
(2).先创建Vue实例,随后再通过vm.$mount(‘#root’)指定el的值
举例:
const x = new Vue({
}
}
})
x.$mount('#root');
2.data有2种写法
(1).对象式
举例:
new Vue({
el:'#root',
data:{
name:'小明'
}
})
(2) 函数式
举例:
const x = new Vue({
data: function(){
return {
name:'小明'
}
}
})
x.$mount('#root');