Also habe ich eine Liste und ich erstelle Karten auf das, es sieht so aus.Wie behalte ich die Referenz eines Artikels in der gefilterten Liste in vue2
var vm = new Vue({
components: {
'card': card
},
el: '#demo',
data: {
customers: [{
id: '1',
name: 'user 1',
amount: '123.24',
profile_pic: 'https://i.stack.imgur.com/CE5lz.png',
email: '[email protected]',
phone: '+91959657248',
unread: '0'
}, {
id: '2',
name: 'user 2',
amount: '34.44',
profile_pic: 'https://i.stack.imgur.com/CE5lz.png',
email: '[email protected]',
phone: '+919456664023',
unread: '0'
}, {
id: '3',
name: 'user 3',
amount: '1.24',
profile_pic: 'https://i.stack.imgur.com/CE5lz.png',
email: '[email protected]',
phone: '+919566565065',
unread: '0'
}, {
id: '4',
name: 'user 4',
amount: '123.24',
profile_pic: 'https://i.stack.imgur.com/CE5lz.png',
email: '[email protected]',
phone: '+916466004566',
unread: '0'
}],
query: '',
},
computed: {
tableFilter: function() {
return this.findBy(this.customers, this.query, 'name')
}
},
methods: {
findBy: function(list, value, column) {
return list.filter(function(item) {
return item[column].includes(value)
})
},
updateComission(commission, id) {
console.log(id);
alert('I am parent need to update data');
}
}
})
ich den Betrag in der Karte aktualisiert werden soll, wenn die Schaltfläche ‚+‘ angeklickt wird, ich tat vorher den Index der Liste, aber jedes Mal Liste gefiltert wird der Index geändert wird und es war die Aktualisierung der falschen Daten.
Jede Idee, wie kann ich dieses Problem beheben
@WannyMiarelli Ja, bitte überprüfen Sie die Js Fiddle – Vikram