子组件中watch获取不到data中的值的解决方法

237 阅读1分钟

watch中的变量可以这么写

  watch: {
    clickWord: {
      immediate: true, // 很重要!!!
      handler(current, old) {
        console.log(current,old)
        this.keywords1 = current;
      }
    }
  }

其中immediate表示立即执行后面的函数