vue 父组件调用子组件方法
父组件: 在子组件中加上ref即可通过this.$refs.ref.method
(ref为引用组件时定义的值,如<children ref="child"></children>
)调用
<template>
<div>
<children ref="child"></children>
</div>
</template>
<script>
import children from 'components/children/children.vue'
export default {
components: { children },
methods:{
parentMethod() {
this.$refs.child.childMethod();
}
}
}
</script>