this.$watch() 的使用(这里可以放在Vue生命周期钩子里):

this.$watch('query', (newQuery) => {
            this.$emit('query', newQuery)
        })

watch:{}的使用(一个方法):

watch:{
  query(newQuery){
    this.$emit('query', newQuery)
  }
}
Logo

Vue社区为您提供最前沿的新闻资讯和知识内容

更多推荐