a () {
return new Promise((res, rej) => {
// :
getData().then(res => {
this.data = res.data.reslut
console.log(this.data)
})
});
}
the a method is defined in vue , and the a method is called in the click event of a button. The desired effect is that after the a method is executed, the alert is executed as follows:
click () {
this.a().then(()=> {
alert(11)
})
}
in this way, the a method is in effect, but the following alert (11) is not triggered. Is something wrong? Or the writing is fundamentally wrong, please give me some advice.
