
vue子组件使用v
当子组件使用了v-if时,父组件想调用子组件的函数就要等子组件的状态改变后才能获得。直接调用将无法获得,需要使用this.$nextTick
例如:
<div> <button @click="getChild"></button> <edit v-if="showEdit" :editNode="editNode" ref="editeven"></edit> </div> data(){ return { showEdit: false } }, methods: { getChild(){ this.showEdit = true; this.$nextTick(function(){ this.$refs.editeven.getNode(); }) } }希望有帮助
👁️ 阅读量:0
© 版权声明:本文《vue子组件使用v》内容均为本站精心整理或网友自愿分享,如需转载请注明原文出处:https://www.zastudy.cn/wen/1686497782a270639.html。