当子组件使用了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子组件使用v-if父组件调用子组件函数时的问题