vue-ant design 在model组件中父组件调用子组件方法

需求逻辑:ant design vue 中有个model组件,使用是页面点击按钮,弹出浮框,浮框内的数据和样式是自定义的子组件。

要做到的是每次点击按钮子组件的数据都要重新请求。封装成组件方法fnChildAjax(){}

正常的调用子组件的方式是在父组件中,子组件内添加ref属性,从父组件中可以获取到ref内的子组件和方法。

比如:parent.page.vue:

<child  ref="isChild" />

methods:{

  this.$refs.isChild.fnChildAjax()

}

但是如果在model内调用此方法,就要注意了:在model显示隐藏有个过渡期所以会获取不到ref

解决:设置个异步延时即可

showModal(type) {//显示model-编辑---------------

this.time1 = setTimeout(()=>{//注意form组件在model内 在model显示隐藏有个过渡期所以会获取不到ref
this.$refs.isChild.fnChildAjax()
},1)

},

 

posted @ 2020-11-11 11:17  少哨兵  阅读(3007)  评论(0编辑  收藏  举报