Loading

Vue-watch同时监听多个变量

Vue2版本:

computed: {
	watchAll() {
		const { a, b } from this
		return { a, b }
	}
}
watch: {
	watchAll(val) {
		console.log(val) // { a: ..., b: xxx }
	}
}

Vue3版本:

watch(
  () => [store.state.date, store.state.hospitalId],
  ([newDate, newId]) => {
     if (newDate && newId) {
       init()
     }
   }
)
posted @ 2021-12-06 15:14  顾诚的城  阅读(1846)  评论(0)    收藏  举报