admin管理员组

文章数量:1794759

vue子组件使用v

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(); }) } }

希望有帮助

本文标签: 组件Vue