created() {
this.function1().then(data=>{
console.log("data===",data)
this.function2();
})
},
methods: {
function1(){
return new Promise((resolve, reject) => {
service.fun(res=>){
this.a=res
}
resolve(this.a)
})
},
function2(){
console.log("输出2")
},
1、resolve
fun1执行成功后调用的函数,相当于return 执行成功的结果。即.then(data)里面的data就是this.a
2、func2
fun1执行完成后 resolve之后 执行fun2