js:
let data = “接口数据”;
var myArray = {};
var funrowSpan =(data,main)=>{
myArray[main] = [];
var x = "";
var count = 0;
var startindex=0;
for(var i = 0;i<data.length;i++){
var val = data[(i)][main];
if(i==0){
x=val;
count=1;
myArray[0]=1
}else{
if(val==x){
count++;
myArray[main][startindex]=count;
myArray[main][i]=0
}else{
count = 1;
x=val;
startindex=i;
myArray[main][i]=1
}
}
}
}
funrowSpan(data,"filed1");//
funrowSpan(data,"filed2");//
columns字段返回:
render: (data, row, index) => {
const obj = {
children: data || '-',
props: {}
};
obj.props.rowSpan = myArray["filed1"][index];
return obj;
}
render: (data, row, index) => {
const obj = {
children: data || '-',
props: {}
};
obj.props.rowSpan = myArray["filed2"][index];
return obj;
}