一开始用concat进行拼接,总是不行,代码如下:
handleItemChange(e){ console.log(e) var itemList = e.detail.value itemList.forEach(item =>{ var row = item.split(\',\') var list = [] const obj = {name: row[1],value: row[0]} list.push(obj) this.setData({ ids: this.data.ids.concat(row[0]), names: this.data.names.concat(row[1]), tagList: this.data.tagList.concat(list) }) })
后来用...展开再进行拼接就可以了:
handleItemChange(e){ console.log(e) var itemList = e.detail.value itemList.forEach(item =>{ var row = item.split(\',\') var list = [] const obj = {name: row[1],value: row[0]} list.push(obj) this.setData({ ids: this.data.ids.concat(row[0]), names: this.data.names.concat(row[1]), tagList: [...this.data.tagList,...list] }) })
请发表评论