??var?arrT?=?["249,胡皓楊",?"287,小小",?"256,涂子航",?"263,胡熠宸",?"169,小麗麗",?"199,裴宗碩",?"270,李二狗",?"245,王嘉沐",?"282,崔一一",?"252,劉哲瀚",?"291,易建聯(lián)",?"259,丁紫依",?"175,鄧頤雪",?"266,方悅溪",?"212,王五博",?"278,吃多多",?"248,周歆悅",?"286,王思聰",?"255,胡若凌",?"262,王為灝",?"168,王二",?"198,兜兜兜",?"269,丁舒宇",?"244,易小樂",?"281,丁玉函",?"251,宋文蕊",?"290,黃蓉",?"258,張晟宇",?"265,胡菁",?"172,覃冉爾",?"206,李小楊",?"274,李宇涵孩子",?"247,胡義豪",?"285,王小小",?"254,吳欣平",?"261,胡芮誠",?"195,章蔚青",?"268,程燁堃",?"243,馬夢琪",?"280,丁子怡",?"250,覃冉爾",?"289,郭靖",?"257,胡耀宇",?"264,葉恩哲",?"171,丁紫依",?"201,李颯",?"272,22",?"246,徐銘鴻",?"284,李小小",?"253,應尚洋"]
1:? ?var?arrT2?=?[]
???for?(var?i?=?0;?i?<?arrT.length;?i++)?{
???????arrT2.push(arrT[i].split(',')[0])
???}
???console.log(arrT2);
2:var?arrT2?=?[]
???arrT2?=?arrT.map(item?=>?item.split(',')[0]?)
二剂公、數(shù)組中元素添加id
?const?selectStudent?=??[...?this.userNameList]
??????const?Student?=?[]
??????for(var?key?in?selectStudent)?{
????????let?obj?=?new?Object();
????????console.log("kkk",selectStudent[key]);
????????obj.stuId?=?selectStudent[key]
????????Student.push(obj)
??????}
??????console.log("sss",[...?Student]);
?//穿梭框提交學生
????submitAdd:?function(){
??????console.log("學生",this.userIdList);
??????const?selectStudent?=?this.userIdList.map(item?=>item.split(',')[0])
??????console.log(666,selectStudent);
? ? ? let?obj1?=??Object.assign({},this.userIdList)
? ? ? let?resultArr?=?[];
? ? ? for(?var?key?in?obj1){
? ? ? ? ? let?obj?=?new?Object();
? ? ? ? ? ?obj.id?=?obj1[key].split(',')[0]
? ? ? ? ?obj.name?=?obj1[key].split(',')[1]
? ? ? ? ?resultArr.push(obj)
? ? ? }
? ? ? ?resultArr.forEach((item)?=>{
? ? ?console.log(1244,item.id);
? ? ? ?this.selectStudent.push(item.id)
? ? ?})
? ? ? console.log(99999,this.selectStudent);
return?selectStudent.forEach((item)=>{
? ?console.log(78,item[0]);
? ? ? ?})
????},
11:給數(shù)組中元素添加id與name
?let?list?=?['31,王小明','1000,八重櫻','200,卡蓮'];
????????let?obj1?=??Object.assign({},list)
????????console.log(obj1)
????????let?resultArr?=?[];
????????for(?var?key?in?obj1){
????????????let?obj?=?new?Object();
????????????obj.age?=?obj1[key].split(',')[0]
????????????obj.name?=?obj1[key].split(',')[1]
????????????obj.id?=?'id'?+?new?Date().getTime();
????????????resultArr.push(obj)
????????}
????????console.log(resultArr);
22:
?let?list?=?['31,王小明','1000,八重櫻','200,卡蓮'];
????????let?obj1?=??Object.assign({},list)
????????console.log(obj1)
????????let?resultArr?=?[];
????????for(?var?key?in?obj1){
????????????let?obj?=?new?Object();
????????????obj.age?=?obj1[key].split(',')[0]
????????????obj.name?=?obj1[key].split(',')[1]
????????????resultArr.push(obj)
????????}
????????console.log(resultArr);