1 父调用子方法
html写:// Game是我自定义的组件
<Game v-if="gameNumberfive != ''" ref="child1">
</Game>
跟页面渲染前后有关 ,所以在调用的方法之前加上this.$nextTick
this.$nextTick(() => {
this.$refs.child1.startFun(this.gameNumberfive)
});
1 父调用子方法
html写:// Game是我自定义的组件
<Game v-if="gameNumberfive != ''" ref="child1">
</Game>
跟页面渲染前后有关 ,所以在调用的方法之前加上this.$nextTick
this.$nextTick(() => {
this.$refs.child1.startFun(this.gameNumberfive)
});