很久很久不用iframe了。最近做项目竟然全部用是iframe,各种不会各种查。。
this.loadingProcess(data); 接口返回的data。父页面赋值各子页面
loadingProcess(data) { this.data = data; //循环各页面赋值 this.activitys.forEach(obj => { let activity = obj.statusCode; let obj1 = window.frames[activity + "IFRAME"];//获得对应iframe的window对象 if (obj1 != undefined) { obj1.vm.assignment(data, this.formObj); } }); },
同级页面 调用方法,取值获取等
saveAccp() { // parent.frames[iframe的name].vm (当前name的实例) let objDiag = parent.frames["DIAGIFRAME"].vm let objCompt = parent.frames["COMPTIFRAME"].vm let objRepair = parent.frames["REPAIRIFRAME"].vm let objRevup = parent.frames["REVUPIFRAME"].vm let objDpk = parent.frames["DPKIFRAME"].vm let objTest = parent.frames["TESTIFRAME"].vm let objShip = parent.frames["SHIPIFRAME"].vm let commentDto = { acceptComment: this.accpObj.acceptComment }; obj.commentDto = commentDto; // obj.activity = parent.vm.formObj.activity var url = parent.window.parent.vm.rmsServerUrl + '/accp/insertAccp'; axios.post(url, obj).then((response) => { if (response.status === 200 && response.data !== "") { var data = response.data; // 调用其他页面内的方法 wipeData()// 一个情况的方法 objDiag.wipeData() objCompt.wipeData() objRepair.wipeData() objRevup.wipeData() objDpk.wipeData() objTest.wipeData() objShip.wipeData() //父页面赋值 // parent.vm.loadingNexeNodeAndGiveValue(data.obj.rmsRepairStatus); } }).catch(function (error) { console.log(error); }) },