用es6
第一种: ...item根据你的需求,可要可不要
let arr = [
{id: 1, title: "绑定手机"},
{id: 2, title: "实名认证"},
{id: 3, title: "游戏分享任务"},
{id: 12, title: "游戏体验任务"},
{id: 13, title: "游戏时长任务"}
]
const res = arr.map(item=>({...item, label: item.title, value: item.id}))
console.log(res);
第二种: 比较傻瓜的
let arr = [
{id: 1, title: "绑定手机"},
{id: 2, title: "实名认证"},
{id: 3, title: "游戏分享任务"},
{id: 12, title: "游戏体验任务"},
{id: 13, title: "游戏时长任务"}
]
let arrNew = arr.map((item) => {
item.label = item.title
item.value = item.id
return item
})
console.log(arrNew);
好好生活-_-