Vuejs can't access refs from component

后端 未结 7 1362
终归单人心
终归单人心 2020-12-17 07:45

I am trying to get the canvas element which is inside a template of a component, found great documentations for vuejs1 but not for vuejs2 where "ref" is the only w

7条回答
  •  猫巷女王i
    2020-12-17 08:22

    You can use $nextTick() function, code inside $nextTick() will run after DOM update.

    this.$nextTick(function () {
    
        console.log(this.$refs.ANY_COMPONENT_REF)
    
    })
    

提交回复
热议问题