期望效果:
element Cascader数据库拿回数据回显问题
代码实现:
var MenuDtae=this.formUpdata.MenuIds.split(’,’);
//去重
function unique5(array){
var r = [];
for(var i = 0, l = array.length; i < l; i++) {
for(var j = i + 1; j < l; j++)
if (array[i] === array[j]) j = ++i;
r.push(array[i]);
}
return r;
}
var newDate=unique5(MenuDtae);
let baseArray = newDate;
this.optionProps.MenuId=[];
//将数据转换为二维数组
for (var j=0;j<baseArray.length;j++){
for (var i=0;i<this.newmenuList.length;i++){
if (this.newmenuList[i].MenuIdbaseArray[j]){
if (this.newmenuList[i].ParentId
0){
this.optionProps.MenuId.push(baseArray[j]);
}else {
let temp = [this.newmenuList[i].ParentId, baseArray[j]];
this.optionProps.MenuId.push(temp);
}
}
}
}

相关文章: