otherUserNames: "甲,乙,丙,丁"
otherUserIds: "10008750,10008711,10003348,10008747"
otherUserAvatars:'头像地址,头像地址2,头像地址3.头像地址4'
首先数据上面是在data里面拿到的
原理首先将字符串转换成数组
if(otherUserAvatars){ let obj={}, 先定义一个对象来装n个对象 for(var i=0;i<otherUserAvatars.split(',').length;i++){ obj['manager'+i]={},//首先创建出需要的数据 let otherUserAvatars=otherUserAvatars.split(','); obj['manager'+i].avatar=otherUserAvatars[i]; let otherUserNames=otherUserNames.split(','); obj['manager'+i].name=otherUserNames[i]; let otherUserIds=otherUserIds.split(','); obj['manager'+i].id=otherUserIds[i]; } //这里再加一个空情况的判断
let otherUserAvatars=otherUserAvatars.split(",");
if(otherUserAvatars.length!==0){
for(let i in obj){
this.managerOtherUserList.push(obj[i]);//然后把对象里面的每一项写入数组中
}
}
}