vue监视器@Watch的immediate参数,表示在watch中首次绑定的时候,是否执行handler函数,
1.值为true则表示在watch中声明的时候,就立即执行handler方法,
2.值为false,则和一般使用watch一样,在数据发生变化的时候才执行handler。
async created() {
// await this.refreshMessageBody()
}
@Watch('message',{
immediate:true,
// immediate表示在watch中首次绑定的时候,是否执行handler,
// 值为true则表示在watch中声明的时候,就立即执行handler方法,
// 值为false,则和一般使用watch一样,在数据发生变化的时候才执行handler。
})
async refreshMessageBody(){
console.log("message改变了");
await this.func1();
await this.func2();
}