Vuejs can't access refs from component

后端 未结 7 1378
终归单人心
终归单人心 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:20

    In may case, I use v-for like:

  • And

     //pubList is from ajax
     props: ['pubList'],
    

    In this case, I solve this by:

      watch: {
        'pubList': {
            handler:function(newArray) {
                 if(newArray.length===0){
                    return
                  }
                 this.$nextTick(function() {
                   console.log(this.$refs.lazyImages)
                 })
              },
           immediate:true
        }
      }
    

提交回复
热议问题