当前位置:网站首页>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();
}
});
边栏推荐
- Redis设计与实现(五)| Sentinel哨兵
- MySQL cannot connect to the intranet database
- Dlib library blink
- 【NVMe2.0b 14-5】Firmware Download/Commit command
- 奇迹MU服务器租用选择 真实好用 稳定不卡 还能防入侵
- Cesium learning notes (I)
- Experiment 6 examination
- Full stack performance testing theory - Summary
- 【花雕体验】12 搭建ESP32C3之Arduino开发环境
- How CRM & PM helps enterprises create optimal sales performance
猜你喜欢

1162 Postfix Expression

Acreems energy efficiency management platform escorts the power safety of high-rise residential areas

跳槽字节跳动很难嘛?掌握这些技巧,你也能轻松通过

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

微信小程序使用vant weapp报错

Graffiti Wi Fi & ble SoC development slide strip

Is it difficult to jump job ByteDance? With these skills, you can easily pass

Sword finger offer II 075 Array relative sort (custom sort, count sort)
![[tensorflow GPU] building of deep learning environment under windows11](/img/10/6d30d4c310e6677049a1012d47f773.png)
[tensorflow GPU] building of deep learning environment under windows11

Applet uses QR code plug-in
随机推荐
Deep learning - residual networks resnets
【NVMe2.0b 14-6】Format NVM、Keep Alive、Lockdown command
Palindrome substring, palindrome subsequence
多快好省,低门槛AI部署工具FastDeploy测试版来了!
Do you know the IP protocol?
Conversion between basic data types in go data types
Recurrence relation (difference equation) -- Hanoi problem
MIME type Encyclopedia
Cesium learning notes (I)
Introduction to opencv (I): image reading and display
【NVMe2.0b 14-6】Format NVM、Keep Alive、Lockdown command
How to handle the expired data of redis and what are the elimination mechanisms?
奇迹MU服务器租用选择 真实好用 稳定不卡 还能防入侵
Miracle Mu server rental selection is real and easy to use, stable and intrusion proof
Experiment 3 remote control
Cesium learning notes (IV) visual image & Terrain
涂鸦Wi-Fi&BLE SoC开发幻彩灯带
Niuke Xiaobai month race 52
[flower carving experience] 12 build the Arduino development environment of esp32c3
F12 packet capture is used for the whole process analysis of postman interface test