layui实现打印layer.open弹窗内容

2024-10-16实例代码
308

parent.layer.open({ //在父窗口打开
                    type: 2,  //type必须为2,否则打印时候获取不到iframe
                    btn: ['打印','关闭'],
                    title: parent.bigOpenTitle + parent.bigOpenContent + "<div class="big-open-title">表单</div>",
                    offset: 'auto',
                    skin: 'big-open',
                    area: ['50vw', '80%'], //宽高
                    content: ‘’,(路径)
                    success: function (layero, index) {
                        var iframe = parent['layui-layer-iframe' + index];
                        parent.$("#layui-layer" + index + " .layui-layer-content")
                            .css("cssText", "background-color: wheat;height:calc(100% - 12vh)!important")
                    },
                    yes: function (index, layero) {
                        var body = parent.layer.getChildFrame('body', index);
                        var iframe = parent[layero.find('iframe')[0]['name']];
                        iframe.print();
                    }

                });
 
The End
弹窗打印

相关推荐