1.通过方法传参
2.通过属性传参
<template>
<view>
<button data-index="11" type="primary" @click="clickBtn(1, $event)">点击事件1</button>
<button data-index="22" type="primary" @click="clickBtn(2, $event)">点击事件2</button>
</view>
</template>
<script>
export default {
methods: {
clickBtn(index, event) {
console.log(index)
console.log(event)
// 获取data-index的值
console.log(event.currentTarget.dataset.index)
}
}
}
</script>
<style>
</style>