子组件调用父组件的方法:
父组件中定义好了方法 hello(),在子组件中直接用this.$parent.hello();
this.$parent.hello();
父组件调用子组件的方法:
<template>
<child ref="pass"></child>
</template>
<script>
methods:{
useMyChildAPI(){
this.$refs.pass.fn1;
}
}
</script>
子组件调用父组件的方法:
父组件中定义好了方法 hello(),在子组件中直接用this.$parent.hello();
this.$parent.hello();
父组件调用子组件的方法:
<template>
<child ref="pass"></child>
</template>
<script>
methods:{
useMyChildAPI(){
this.$refs.pass.fn1;
}
}
</script>