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

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

vue 數值對象和對象 indexOf()問題

vue 數值對象和對象 indexOf()問題

慕田峪9158850 2018-11-13 12:53:09
現在的函數const index1 = JSON.stringify(this.selectGame).indexOf(JSON.stringify(item1)); ???下面要怎么寫,如果點擊時對象數組this.selectGame中包含有對象item1,就刪除當前點擊的對象之前的函數    //點擊選擇收藏的內容     check_show(item1) {       const index1 = this.selectGame.indexOf(item1);      // let aa = { idName:item.Id,nameId:item.Name}       if(index1 > -1 ){        this.selectGame.splice(index1, 1)       }else if(this.selectGame.length < 10){        this.selectGame.push(item1);       }     },上面的函數在 this.selectGame.push(item1);執行中添加進的元素有效,如果是selectGame中途就已經包含有元素,就不能起作用于是我用JSON.stringify將item1都轉成了字符串,但是問題是indexOf出來的結果是字符串的長度,像是317,175,818,2500之類的,就不能用this.selectGame.splice(index1, 1)將包含有的函數按照位置刪除
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 1541 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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