第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

刪除數(shù)組中的元素,怎么將刪除元素的id組成一個(gè)數(shù)組

刪除數(shù)組中的元素,怎么將刪除元素的id組成一個(gè)數(shù)組

皈依舞 2019-03-06 18:15:44
removeCost: function (item) {  let index = this.form.addReceiptsCostVOList.indexOf(item)    let ids = []  for (var i = 0; i < this.form.addReceiptsCostVOList.length; i++) {    ids.push(item.costId)    this.form.delCostIds = ids  }  if (index !== -1) {      this.form.addReceiptsCostVOList.splice(index, 1)    }      console.log('form', this.form)}想著在刪除一條數(shù)據(jù)后,獲取刪除數(shù)據(jù)的id,組成一個(gè)數(shù)組,怎么刪除多條數(shù)據(jù),獲取多個(gè)id ,怎么設(shè)置循環(huán)條件
查看完整描述

3 回答

?
飲歌長嘯

TA貢獻(xiàn)1951條經(jīng)驗(yàn) 獲得超3個(gè)贊

removeCost: function (item) {

  let index = this.form.addReceiptsCostVOList.indexOf(item)

  let ids = []

  for (var i = 0; i < this.form.addReceiptsCostVOList.length; i++) {

    ids.push(item.costId)

  }

  this.form.delCostIds = ids

  for (let i = 0; i < ids.length; i++) {

    this.form.addReceiptsCostVOList.splice(ids.length - 1 - i, 1)

  }

  console.log('form', this.form)

}


查看完整回答
反對(duì) 回復(fù) 2019-03-21
?
繁華開滿天機(jī)

TA貢獻(xiàn)1816條經(jīng)驗(yàn) 獲得超4個(gè)贊

可以考慮 filter 過濾掉包含 item數(shù)組里的id的元素


查看完整回答
反對(duì) 回復(fù) 2019-03-21
?
慕碼人8056858

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超6個(gè)贊

可以考慮使用閉包函數(shù)改造一下, 需要注意下this指向


removeCost: (() => {

  let ids = []

  this.form.delCostIds = ids

  return (item) => {

     let index = this.form.addReceiptsCostVOList.indexOf(item)

     if (index !== -1) {

         ids.push(item.costId)

         this.form.addReceiptsCostVOList.splice(index, 1)

     }

  }

})()


查看完整回答
反對(duì) 回復(fù) 2019-03-21
  • 3 回答
  • 0 關(guān)注
  • 740 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)