constskutitle=[{label:"颜色",prop:"val",},{label:"尺寸",prop:"val1",},{label:"形状",prop:"val2",},{label:"规格",prop:"val3",}]//表格头consttableData=[{val:"红",val1:"大",val2:"五边形",val3:"1*222",price:"22"},{val:"绿",val1:"大",val2:"6边形",val3:"1*2224",price:"2244"},{val:"蓝",val1:"大",val3:"1*225",val2:"八边形",price:"2244"}]constall=[{'颜色':"蓝",'尺寸':"大",'形状':"八边形",'规格':"1*225",'价格':"2244"}]skutitle数组和tableData数组转成all数组那种数据格式得,目前代码如下functionarrayList(skutitle,tableData){varresult=[]for(leti=0;ivarcol_label=skutitle[i].label varcol_prop=skutitle[i].propvarobj={}for(letj=0;jconsole.log(tableData[j]) varitems=[]for(letkeyintableData[j]){if(skutitle[i].prop===key){obj[skutitle[i].label]=tableData[j][key];console.log(obj,'obj')//items.push(obj)}}console.log(items,"items")result.push(items)}}console.log(result,'77')}arrayList(skutitle,tableData)通过打印是key值判断那边有点问题,没有思路了
沧海一幻觉
繁星coding
相关分类