函数写法的区别:
let vueComponent = {
name:'jack',
created:function() { // 前两个this指向一样
console.log(this)// 当前对象
},
created1() {
console.log(this) // 当前对象
},
created2: () => {
console.log(this) // window,上层
}
}
vueComponent.created();
vueComponent.created1();
vueComponent.created2();
运行结果