<html>
<body>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
//vue则直接将script中的代码写入对应的方法中
let aa="A,B,C,d";
// 将字符串aa转换为数组
let newAa=aa.split(',');
// 将两个数组的值分别作为新数组的value值
let a=["A","B","C","D"];
let b=[1,2,3,4];
let newArray = [];
a.forEach((value,index) => {
newArray[index] = {venue:a[index],num:b[index]}
})
console.log(newArray);
// 合并的数组为以下形式
newArray=[
{venue:A,num:1},
{venue:B,num:2},
{venue:C,num:3},
{venue:D,num:4},
]
</script>
</body>
</html>
更多字符串操作(如有侵权,联系删除):
https://blog.youkuaiyun.com/AAAXiaoApple/article/details/122209023