背景
想用watch来监视input标签的值,但是发现总是慢一步,比如:我输入123,但是在watch里赋值却是12
错误示例
watch:{
searchValue(oldV,newV){
this.$store.state.userManage.filters.searchCondition=newValue
console.log(this.$store.state.userManage.filters.searchCondition)
}
}
错误原因
handler传入的参数依次是 新的值、旧值。我把顺序搞反了。
解决示例
watch:{
searchValue(newV,oldV){
this.$store.state.userManage.filters.searchCondition=newValue
}
}