父级页面
layer.open({
type: 2,
area: [w+'px', h +'px'],
fix: false, //不固定
maxmin: true,
shade:0.4,
shadeClose: true,
title: title,
content: url,
btn: ['确定','关闭'],
yes: function(index){
//当点击‘确定’按钮的时候,获取弹出层返回的值
var res = window["layui-layer-iframe" + index].callbackdata();
//打印返回的值,看是否有我们想返回的值。
console.log(res);
$('#goods').html(res['kids']);
//最后关闭弹出层
layer.close(index);
},
cancel: function(){
//右上角关闭回调
}
子级页面
var callbackdata = function () {
kid = getChecked().toString();
var data = {
kids: kid
};
return data;
}
父级页面的callbackdata()方法就是子级页面的返回值