//职业照if(res.data.posterUrl){this.ruleForm.jobImg.push({file:{},src:res.data.posterUrl,isShowDel:true,load:"ok"});}//身份证正面if(res.data.idCardFrontPic){this.ruleForm.id1.push({file:{},src:res.data.idCardFrontPic,isShowDel:true,load:"ok"});}//身份证反面if(res.data.idCardBackPic){this.ruleForm.id2.push({file:{},src:res.data.idCardBackPic,isShowDel:true,load:"ok"});}获取数据后我会做以上处理,但中间有很多是重复了,我不知道该怎么封装它们这怎么封装比较好呢?
2 回答
人到中年有点甜
TA贡献1895条经验 获得超7个赞
这样?:methods:{pushData(res,ruleForm,prop1,prop2){if(res.data[prop1){ruleForm[prop2].push({file:{},src:res.data[prop1],isShowDel:true,load:"ok"});}returnruleForm;}}然后调用:this.pushData(res,this.ruleForm,'posterUrl','jobImg');
一只名叫tom的猫
TA贡献1906条经验 获得超3个赞
letpushSrc=res.data.posterUrl||res.data.idCardFrontPic||res.data.idCardBackPic;this.ruleForm.id2.push({file:{},src:pushSrc,isShowDel:true,load:"ok"});这样子?
添加回答
举报
0/150
提交
取消