layui 弹窗的iframe 父子界面相互传值

1.父界面向子界面传值

  [1].父界面打开子界面:

function show_layer(){
layer.open({
        type: 2,
        area: [w+'px', h +'px'],
        fix: false, //不固定
        maxmin: true,
        shadeClose: true,
        shade:0.4,
        title: title,
        content: url,  //url 为子布局的url路径
        success:function (layero,index) {
                var iframe = window['layui-layer-iframe' + index];
                iframe.child('我是父布局传到子布局的值')
        }
    });
}

  [2].子界面接收父界面的值

function child(obj){
    console.log(obj);//获取父界面的传值
}

2.子界面向父界面传值

  [1].子界面向父界面传值

parent.GetValue('我是子界面的数值'); //GetValue是父界面的Js 方法
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);

  [2].父界面接收子界面的值

function GetValue(obj){
    console.log(obj);
}



猜你喜欢

转载自www.cnblogs.com/yysbolg/p/9977387.html