這是我第一次在 vue.js 中處理數據表,所以我從 api 中提取了 teams.id,并將其設置為數據表中每一行的唯一鍵。我的問題是我無法將密鑰傳遞給“刪除”功能。我能夠獲取索引,但我無法找到獲取所述行的鍵的方法。<v-data-table:headers="headers":items="teams":key="teams.id"sort-by="id"class="elevation-1"><template v-slot:item.actions="{ item }"><v-icon small @click="deleteItem(item)"> fas fa-trash</v-icon></template></v-data-table>deleteItem(item) { const index = this.teams.indexOf(item) if(confirm('Are you sure you want to delete this item?')) { axios.delete(this.apiUrl+index).then(resp => { this.teams.splice(index, 1) }) }},謝謝!
Vue.js - 將行的鍵傳遞給函數
慕碼人8056858
2022-06-09 19:10:55