问题描述下面的代码输出2,如何传递参数才能在**调用函数**的时候输出**函数创建时**的rid值:1求除了使用不同变量名之外的其它解决方案,谢谢~相关代码varrid=1;varf1=(id=rid)=>{console.log(rid);}rid=2;f1();//输出2,如何能让输出f1函数创建时候的rid值:1下面是原始代码//获取任务列表varrid=this.getRid();action={rid:rid,action:'getTasks'}this.$store.state.ws.eventList[rid]=(d,id=rid)=>{vardata=d.data;if(data.length>0){for(variindata){this.$store.state.task.taskList.push(data[i]);}}deletethis.$store.state.ws.eventList[id];}this.$store.state.ws.websocket.send(JSON.stringify(action));//获取好友列表rid=this.getRid();action={rid:rid,action:'getFriends'}this.$store.state.ws.eventList[rid]=(d,id=rid)=>{vardata=d.data;if(data.length>0){for(variindata){data[i].nickname=data[i].nickname?data[i].nickname:data[i].number;data[i].initial=data[i].initial?data[i].initial:data[i].number.toString().substr(0,1);data[i].headerUrl=data[i].type===1?"http://p.qlogo.cn/gh/"+data[i].number+"/"+data[i].number+"/100/":"http://q.qlogo.cn/headimg_dl?bs=qq&dst_uin="+data[i].number+"&fid=blog&spec=100";this.$store.state.allContacts.push(data[i]);}}deletethis.$store.state.ws.eventList[id];}this.$store.state.ws.websocket.send(JSON.stringify(action));
梵蒂冈之花
森栏
相关分类