大家好
我是 Vue.js 的新手還請多多指教
想請問在 v-for 中產生的很多 Button 按鈕
要怎麼分辨點選的按鈕是哪一個呢
謝謝
HTML:
<template>
<div id="app">
<div v-for="(item, key) in list" :key="key">
<Button label="Click" class="p-button-label p-button-sm" style="float:right" @click="clickBtn" />
</div>
</div>
</template>
JS:
<script>
export default {
name: 'app',
data() {
return {
list: [{"id": "1","title": "animals1"},{"id": "2","title": "animals2"},{"id": "3","title": "animals3"},{"id": "4","title": "animals4"},{"id": "5","title": "animals5"}],
}
}
}
</script>
<template>
<div id="app">
<div v-for="(item, key) in list" :key="key">
<Button label="Click" class="p-button-label p-button-sm" style="float:right" @click="clickBtn('item')" />
</div>
</div>
</template>