el-dialog el-table el-tree this.$refs获取undefined

最近做新迭代任务,点击弹框里的表格里面的按钮,清除树状结构的数据, 但是 r e f s [ ′ e v e n t G r o u p T r e e ′ ] [ 0 ] . s e t C h e c k e d K e y s ( [ ] ) 获取 u n d e f i n e d , 打印出来一看 t h i s . refs['eventGroupTree'][0].setCheckedKeys([])获取undefined,打印出来一看this. refs[eventGroupTree][0].setCheckedKeys([])获取undefined,打印出来一看this.refs[‘eventGroupTree’]为undefined

在网上搜了解决方案有3种:
第一种:页面没有渲染完成----解决不了一点,还是undefined

this.$nextTick(())={
this.$refs['eventGroupTree']
}

第二种: 延时器异步加载------解决不了一点,还是undefined

 setTimeout(() => {
   console.log(this.$refs["childData"].objData);
 }, 10);

第三种: v-if判断他狂开启关闭----------解决不了一点,还是undefined

console.log(this.$refs["childData"].objData);
}

最后的解决方案:

 setTimeout(function () {
          if (that.selectedEventGroup.length != 0) {
            that.$refs['eventGroupTree'][0].setCheckedKeys([])
          }
        }, 500)

ps: 万物变幻莫测,万变不离其中,小学老师说的对!

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值