亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從數組中刪除一個項目?

如何從數組中刪除一個項目?

月關寶盒 2022-06-16 09:50:03
我有這個<span @click="remove(product)" class="btn btn-sm btn-danger"><i class="fa fa-times"></i></span> element, It triggers this function:<br/>remove(product) {  this.form.products.$remove(product);} <br/>但它輸出這個錯誤:TypeError: this.form.products.$remove is not a function我不知道出了什么問題。
查看完整描述

1 回答

?
汪汪一只貓

TA貢獻1898條經驗 獲得超8個贊

使用該splice方法從數組中刪除項目

首先獲取item的索引

let index = this.form.products.indexOf(product);

然后使用刪除它splice

this.form.products.splice(index,1);


查看完整回答
反對 回復 2022-06-16
  • 1 回答
  • 0 關注
  • 119 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號