当前位置:网站首页>layer.open 当传值为数组或值太长时处理方法
layer.open 当传值为数组或值太长时处理方法
2022-06-30 08:10:00 【BlizzardWu】
var data = [{
"name":"160A100A1638.jpg","url":"/public/uploads/160A100A1638.jpg"}];
layer.open({
title: "子页",
type: 2,
content: "/admin/sysconfig/terminal_qrcodelist",
area: ['50%', '70%'],
btn: ["一键下载",'关闭'],
success: function (layero, index) {
//成功获得加载changefile.html时,预先加载,将值从父窗口传到 子窗口
let body = layer.getChildFrame('body', index); //少了这个是不能从父页面向子页面传值的
//获取子页面的元素,进行数据渲染
// body.find(".filename").val(data[0].name); //通过class名进行获取数据
// body.find(".filepath").val(data[0].url);//意思是将rowselect[0].path这个值传递到子窗口的class="filepath"这个的文本框中,(预先加载)
//预先加载一些子页面内容
var html = '';
data.forEach(function(value, key, data) {
html += '<div class="big_box"><div class="img_box"><img src="'+ value.url +'" style="width:100%;" ></div>'+
'<div class="btn_box"><a href="'+ value.url +'" download="'+ value.name +'" class="btn layui-btn-normal radius">下载</a></div></div>';
//console.log(value.url);
});
body.find("#qr_list").html('');
body.find("#qr_list").html(html);
// layui.form.render();
},
yes: function (index, layero) {
//按了弹出层的确定按钮时,这是将在父窗口中获取子窗口form标签里的所有值,并根据name名和值形成键值对json对象
//循环下载所有qrcode
$.each(data, function (i ,item){
let a = document.createElement('a') // 创建a标签
let e = document.createEvent('MouseEvents') // 创建鼠标事件对象
e.initEvent('click', false, false) // 初始化事件对象
a.href = item.url // 设置下载地址
a.download = item.name // 设置下载文件名
a.dispatchEvent(e)
});
},
btn2: function (index, layero) {
//layer.close(index);
location.reload();
}
});
边栏推荐
- Fishingprince Plays with Array
- 小心transmittable-thread-local的这个坑
- 【NVMe2.0b 14-6】Format NVM、Keep Alive、Lockdown command
- 在浏览器输入url到页面展示出来
- Miracle Mu server rental selection is real and easy to use, stable and intrusion proof
- Final review -php learning notes 2-php language foundation
- Dlib database face
- Deep learning - goal orientation
- Development technology sharing of Jingtan NFT digital collection system
- 电流探头电路分析
猜你喜欢

Deep learning -- Realization of convolution by sliding window

示波器探头对测量电容负荷有影响吗?

一次cpu 跌底排查

Deep learning - goal orientation

Is it difficult to jump job ByteDance? With these skills, you can easily pass
![[nvme2.0b 14 - 5] commande de téléchargement / commande du logiciel](/img/98/bb250030f3e31e71d48e3be3ea4698.png)
[nvme2.0b 14 - 5] commande de téléchargement / commande du logiciel

F12 packet capture is used for the whole process analysis of postman interface test

Final review -php learning notes 2-php language foundation

Vulfocus entry target

小程序使用二维码插件
随机推荐
Graffiti Wi Fi & ble SoC development slide strip
【NVMe2.0b 14-3】Doorbell Buffer Config command、Device Self-test command
Rendering engine development
C# Console. Writeline() function output format
Wechat applet reports errors using vant web app
Introduction to opencv (I): image reading and display
Unity简单shader
Redis设计与实现(六)| 集群(分片)
Redis设计与实现(七)| 发布 & 订阅
C # about Net cognition
Dlib library blink
1162 Postfix Expression
Redis设计与实现(八)| 事务
C. Fishingprince Plays With Array
Do you know the IP protocol?
【NVMe2.0b 14-6】Format NVM、Keep Alive、Lockdown command
JS code case
Redis设计与实现(五)| Sentinel哨兵
微信公众号第三方平台开发,零基础入门。想学我教你啊
Transformer architecture understanding