关于(this.$el)和(vm.$el)的问题
来源:3-2 Vue实例生命周期

粉红色的小猪佩奇
2019-12-04
mounted:function(){
console.log(this.$el)
console.log(vm.$el)
console.log("mounted")
},
为什么(this.KaTeX parse error: Expected 'EOF', got '可' at position 5: el) 可̲以打印出来,(vm.el)就报错呢
写回答
2回答
-
Dell
2019-12-07
因为此时还没有走到对vm赋值的过程,vm还是空,所以没有办法用vm
00 -
呀呀呀亚歌
2019-12-04
根据打印,那个vm是undefined的,因为在mounted里面这个vm = new Vue({})还没有赋值完成,还没有挂载在window对象上,但是如果在赋值语句的外部还是能这么使用的
00
相似问题