[Vue.js 2]リスト内を検索してあれば更新する例
リストの中のオブジェクトを検索して、あればそのオブジェクトを更新するにはどうしようかな、となって以下のように書いた。
// listからidで探して更新する
updateListItem2(list, value) {
const idx = list.findIndex((item) => item.id === value.id);
if (idx !== -1) {
list.splice(idx, 1, value);
}
}findIndexでIndexを探して、splliceで置き換える。
Vueでは、dataの変更をして、変更の結果がすぐにview側に反映されるようにするには、指定された関数を使う必要がある。今回はspliceを使った。





ディスカッション
コメント一覧
789bet09 – keep hearing this mentioned. Anyone had any good experiences there? Thinking of giving it a go. Let’s check 789bet09 out!
N188app, mobile gaming here, alright! The app works good and if you’re on the go a LOT like me, its an easy win but is it worth that? Probably. n188app
zulacasinologin, easy to get into, not bad, a solid try for any on the go gamer, if you want to try it out let me know! zulacasinologin
Been checking out plataforma592bet and gotta say, it’s pretty smooth. Easy to navigate and found some games I really dig. Solid for a quick bet or a longer session. Check it out at plataforma592bet.