Vuejs can't access refs from component

后端 未结 7 1341
终归单人心
终归单人心 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条回答
  •  抹茶落季
    2020-12-17 08:32

    i had the exact same issue, in my case i solved it by accessing the ref in the method that changes the v-if with nextTick.

    methods: {
    open() {
      this.show = true; //v-if condition
        this.$nextTick(function() {
          this.titleWidth = this.$refs.titleBg.clientWidth - 30;
        });
    }
    

提交回复
热议问题