回调函数(f2)调用全局变量(a)时,指针(this)需在调用函数(f1)里面以参数形式传给回调函数(f2),此时方可调用全局变量(a)
data:{
a:''
},
onLoad(){
this.f1(this.f2)
}
methods:{
f1(callBack)=>{
if(callBack) callBack(this)
}
f2(that)=>{
//调用全局变量
console.log(that.data.a)
}
}
//回调函数(f2)调用全局变量(a)时,指针(this)需在调用函数(f1)里面以参数形式传给回调函数(f2),此时方可调用全局变量(a)