2024年07月14日 建站教程
//数组一后面添加数组二
const typesAdd = [{"id": 0,"type": "请选择"}] const typesAdd2 = [{"id": 1,"type": "中国"}] const typesList = typesAdd.concat(typesAdd2);
//获取数组下标
const checkContent2 = [{"id": 0,"type": "请选择"},{"id": 1,"type": "中国"}]
const valuesNum = []
for (let i = 0; i < checkContent2.length; i++) {
valuesNum.push(i)
}
//数组添加定义ids
const valuesList = []
valuesNum.forEach(function (item) {
valuesList.push({
ids: item
})
});
//两个数组合并
const newsItems = checkContent2.map((item, index) => {
return { ...item, ...valuesList[index] };
});
本文链接:http://so.lmcjl.com/news/8450/