layui 父页面向子页面传参

父窗体js

$('.mytable').on('click', '.editRow', function () {
    var table = $('#table_id_example').DataTable();
    var rowData = table.rows({selected: true}).data()[0];
    if (rowData) {
        layer.open({
            title: this.text,
            type: 2,
            skin: 'layui-layer-rim', //加上边框
            area: [window.screen.width / 2 + 'px', window.screen.height / 2 + 'px'], //宽高
            maxmin: true, //开启最大化最小化按钮
            content: "taskDetail.html",
            success: function (layero, index) {
                // 获取子页面的iframe
                var iframe = window['layui-layer-iframe' + index];
                // 向子页面的全局函数child传参
                iframe.child(rowData);
            }
        })
    } else {
        alert("先选择行")
    }
})

子窗体js

function child(d) {
    alert(d);
    // todo 你的业务代码
    // 可以把传递过来的参数存在layui.cache中, 方便其他方法调用

}
posted @ 2021-02-02 10:18  今天代码写完了吗  阅读(628)  评论(0编辑  收藏  举报