赞
踩
应用场景:后端返回的数据为json类型,但是在使用dataV中的轮播表时,需要的数据类型是一个二维数组(一个大数组嵌套多个数组)的形式。
- const data1 = [
- { prop1: value1, prop2: value2, prop3: value3, prop4: value4, prop5: value5 },
- { prop1: value1, prop2: value2, prop3: value3, prop4: value4, prop5: value5 },
- { prop1: value1, prop2: value2, prop3: value3, prop4: value4, prop5: value5 },
- { prop1: value1, prop2: value2, prop3: value3, prop4: value4, prop5: value5 },
- { prop1: value1, prop2: value2, prop3: value3, prop4: value4, prop5: value5 }
- ];
- const data2 = {
- data: [
- [ value1, value2, value3, value4, value5 ],
- [ value1, value2, value3, value4, value5 ],
- [ value1, value2, value3, value4, value5 ],
- [ value1, value2, value3, value4, value5 ],
- [ value1, value2, value3, value4, value5 ]
- ]
- }
- let tempList = this.data1
- tempList = tempList.map(item => {
- return [item.prop1, item.prop2, item.prop3, item.prop4]
- })
- this.data2 = Object.assign({}, this.data2, {
- data: tempList,
- });
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。