当前位置:网站首页>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();
}
});
边栏推荐
- String and underlying character types of go data type
- Cesium learning notes (I)
- Final review -php learning notes 2-php language foundation
- 【NVMe2.0b 14-6】Format NVM、Keep Alive、Lockdown command
- Game 280 problem2: minimum operands to turn an array into an alternating array
- 电流探头电路分析
- 多快好省,低门槛AI部署工具FastDeploy测试版来了!
- 【Tensorflow-gpu】window11下深度学习环境搭建
- Wechat applet reports errors using vant web app
- Camera
猜你喜欢

Sword finger offer II 074 Merge interval (sort, array)

Cesium learning notes (III) creating instances

Environment configuration of ROS Aubo manipulator

【NVMe2.0b 14-3】Doorbell Buffer Config command、Device Self-test command

涂鸦Wi-Fi&BLE SoC开发幻彩灯带

How to handle the expired data of redis and what are the elimination mechanisms?

【NVMe2.0b 14-8】Set Features(下篇)

多快好省,低门槛AI部署工具FastDeploy测试版来了!

Sword finger offer II 076 The kth largest number in the array (use heap to solve TOPK problem)

【NVMe2.0b 14-5】Firmware Download/Commit command
随机推荐
牛客小白月賽52
【NVMe2.0b 14-1】Abort、Asynchronous Event Request、Capacity Management command
Emoji icons supported by markdown
Want to change careers, but don't know what to do? This article is written for you who are confused
Redis设计与实现(八)| 事务
CRM能为企业带来哪些管理提升
【NVMe2.0b 14-2】Create/Delete Queue
Vulfocus entry target
CRM&PM如何帮助企业创造最优销售绩效
Opencv image
[notes] polygon mesh processing learning notes (10)
Deep learning - bounding box prediction
Experiment 3 remote control
Cesium learning notes (IV) visual image & Terrain
Experiment 6 examination
[flower carving experience] 12 build the Arduino development environment of esp32c3
【NVMe2.0b 14-6】Format NVM、Keep Alive、Lockdown command
Sword finger offer II 076 The kth largest number in the array (use heap to solve TOPK problem)
Bingbing learning notes: quick sorting
MIME类型大全