vue父组件促发子组件中的方法
实现在父组件中促发子组件里面的方法
子组件:
<template> <div> 我是子组件 </div> </template> <script> export default { name: "child", methods: { parentHandleclick(e) { console.log(e) } } </script>
父组件:
<template>
<div>
<button @click="clickParent">点击我促发子组件方法</button>
<child ref="mychild"></child>
</div>
</template>
<script>
import Child from './child';
export default {
name: "parent",
components: {
child: Child
},
methods: {
clickParent() {
this.$refs.mychild.parentHandleclick("父组件调用子组件方法");
}
}
}
</script>

浙公网安备 33010602011771号