点击按钮的时候发送两个事件
this.$emit('aa', 11)
this.$emit('bb', 22)
<template>
<div>
<button @click="btnClick(index, item)" v-for="(item, index) in option" :key="item.value" :class="[{'active':activeValue===item.value}, 'btn']">{{item.label}}</button>
</div>
</template>
<script lang="ts">
import { Component, Model, Emit, Prop, Vue, Ref, Watch, Provide } from "vue-property-decorator";
@Component({
components: {}
})
export default class extends Vue {
@Model('click') activeValue: any
@Prop({ default: () => [] }) option: any
act = this.activeValue
@Emit('click')
btnClick(index, item) {
this.activeValue = item.value
return this.activeValue
}
mounted() {}
}
</script>
一楼的方法 还是不能返回多个值
换个思路吧, 点击的时候触发一个函数, 这个函数触发两个@emit事件函数