实现功能:想要实现在当前页点击数据列表的某一行,弹出该行数据对应的子页面,其中涉及到将数据列表中的值传递给子页面,并在子页面中调用
1、父页面的监听行单击事件
table.on('row(cat)', function(obj) {
var data = obj.data;//获取当前行的数据
layer.open({
type: 2,
title: '数据详情',
maxmin: true,
area: ['1100px', '600px'],
fixed: false, //不固定
content: 'catDetail.html',
success: function(layero, index) {
var body = layer.getChildFrame('body', index); //获取子页面的dom对象
var iframe = window['layui-layer-iframe' + index];
// 向子页面的全局函数child传参
iframe.child(data)
}
});
})
2、子页面的参数传递
function child(dataFromFather) {
console.log(dataFromFather);
console.log(dataFromFather.id);
}
借鉴方法:
https://blog.csdn.net/qq_25844803/article/details/112240068
其它参考方法:
1、https://segmentfault.com/q/1010000016077154
2、https://www.cnblogs.com/ssh-html/articles/6763296.html
3、方法3