vue的Array坑

221 阅读1分钟

const _toLongArray = [{id:1},{id:2}]
_toLongArray.forEach((item,index)=>{    this.toLongArray.splice(index,1)

})
//当this.toLongArray数据太复杂时,数组删除可能无效
//建议:
var _new = []
_toLongArray.forEach((item,index)=>{    
if(item){
    _new .push(item)}
}
this.toLongArray = _new