watch监听props中的属性,首次传来的props不会触发监听事件的发生
解决:immediate: true,
dksearchResult: {
immediate: true,
handler(newValue) {
this.content = newValue;
console.log(this.content);
}
}
immediate:true代表如果在 wacth 里声明了之后,就会立即先去执行里面的handler方法,如果为 false就跟我们以前的效果一样,不会在绑定的时候就执行。