- 整体思路:
resizeWindow
是在父页面中调用子页面的方法
resizeWindows
是在子页面中调用父页面的方法
toChildValue
是父页面向子页面传数据的方法
父页面
created: function () {
that = this;
window.resizeWindows = function (parentId, zi_id, selfs) {
console.log('我是父页面,可在这里调用父页面中的方法');
};
window.toChildValue = function (parent_id) {
return '我是父页面中的数据';
}
},
methods: {
selectRange(parent_id, id) {
layui.use(['form', 'laydate'], function () {
layer.open({
type: 2,
title: '自定义范围',
btn: ['提交', "取消"],
shadeClose: true,
shade: 0.5,
area: ['800px', '600px'],
content: '/admin/organization/organSearch.html?' + parent_id + '?' + id,
btn1: function (index, layero) {
var iframe_home = document.querySelector('#layui-layer-iframe' + index)
iframe_home.contentWindow.resizeWindow();
},
btn2: function (index, layero) {
}
});
})
},
},
iframe页面(也就是/admin/organization/organSearch.html
页面)
created: function () {
var _this = this;
window.resizeWindow = function () {
return _this.tijiao();
}
var getParentVule = parent.toChildValue(this.parent_id);
},
methods: {
tijiao() {
console.log("我是iframe页面");
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
parent.resizeWindows(this.parent_id, this.zi_id, selfs);
}
}