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("先选择行")
        }
    })

子窗体


<script>
    function child(d) {
      alert(d)
    //在这里你可以写你的jquery $(function(){ })   等等操作


    }
</script>

猜你喜欢

转载自www.cnblogs.com/userzf/p/9448646.html