子组件:child.vue
{
methods: {
setValue(value) {
this.value = value;
}
}
}
父组件:parent.vue
<template>
<div>
<button @click="addValue(1)"></button>
<child ref="box"></child>
</div>
</template>
{
methods: {
addValue(value) {
this.$refs.box.setValue(value)
}
}
}