相关疑难解决方法(0)

如何从父组件中查看子属性更改

我正在使用日期选择器组件库,我想看看该组件的属性何时更改.

我试过这个:

  watch: {
    '$refs.picker.popupVisible': {
      handler (new_value) {
        console.log('executed')
      },
      deep: true
    }
  }
Run Code Online (Sandbox Code Playgroud)

这个:

  computed: {
    picker () {
      console.log(this.$refs.picker.popupVisible)
      return this.$refs.picker.popupVisible
    }
  }
Run Code Online (Sandbox Code Playgroud)

我知道解决方案将是一个vue.js hack,因为这不是正确的方法.如果我有权访问子组件,我会向父母发出en事件但不幸的是我没有.

vue.js vuejs2

5
推荐指数
1
解决办法
2963
查看次数

标签 统计

vue.js ×1

vuejs2 ×1