更新 upload 测试用例

pull/1287/head
贤心 1 year ago
parent 1f4a44fd42
commit fddfed0300

@ -92,9 +92,9 @@ hr{margin: 30px 0;}
<script src="../src/layui.js" src1="https://cdn.staticfile.org/layui/2.6.8/layui.js"></script> <script src="../src/layui.js" src1="https://cdn.staticfile.org/layui/2.6.8/layui.js"></script>
<script> <script>
layui.use(['upload', 'element'], function(){ layui.use(['upload', 'element'], function(){
var $ = layui.jquery var $ = layui.$;
,upload = layui.upload var upload = layui.upload;
,element = layui.element; var element = layui.element;
var uploadInst = upload.render({ var uploadInst = upload.render({
elem: '#test1' elem: '#test1'
@ -103,7 +103,7 @@ layui.use(['upload', 'element'], function(){
//,accept: 'file' //,accept: 'file'
,method: 'get' ,method: 'get'
,fileAccept: 'image/*' ,fileAccept: 'image/*'
,exts: "jpg|png|gif|bmp|jpeg|pdf" ,exts: 'jpg|png|gif|bmp|jpeg|pdf'
,data: { //额外参数 ,data: { //额外参数
a: 1 a: 1
,b: function(){ ,b: function(){
@ -162,7 +162,8 @@ layui.use(['upload', 'element'], function(){
upload.render({ upload.render({
elem: '#test2' elem: '#test2'
,url: 'https://httpbin.org/post' ,url: 'https://httpbin.org/post'
,multiple: true ,multiple: true // 多文件
,unified: true // 一起上传 --- 2.8.8+
,accept: 'images' ,accept: 'images'
,number: 3 //同时上传的数量 ,number: 3 //同时上传的数量
,size: 1024 ,size: 1024
@ -172,18 +173,18 @@ layui.use(['upload', 'element'], function(){
$('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">') $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
}); });
//this.files = obj.pushFile(); // this.files = obj.pushFile();
} }
,done: function(res, index){ ,done: function(res, index){
//上传完毕 // 上传完毕
//console.log(this.files) console.log(res, index)
} }
,allDone: function(obj){ ,allDone: function(obj){
console.log(obj) console.log(obj)
} }
}); });
//演示多文件列表 // 演示多文件列表 --- 本示例仅演示未开启 unified 属性的情况
var demoListView = $('#demoList'); var demoListView = $('#demoList');
var uploadListIns = upload.render({ var uploadListIns = upload.render({
elem: '#testList' elem: '#testList'
@ -247,6 +248,7 @@ layui.use(['upload', 'element'], function(){
} }
,progress: function(n, elem, e, index){ ,progress: function(n, elem, e, index){
console.log(n); console.log(n);
console.log(index);
element.progress('progress-'+ index, n + '%'); //进度条 element.progress('progress-'+ index, n + '%'); //进度条
} }
}); });

Loading…
Cancel
Save