var upload_pic = []; var upload_file = []; var upload = []; function loadUpload(i,e,key,upload) { var value = e.attr('v'); upload[value] = true; var id = e.attr('id'); layui.use(['upload','layer'], function() { var layer = layui.layer; var layer_1 = false; var layuiUpload = layui.upload; var uploadInst = layuiUpload.render({ elem: '#' + id ,data: {'key' : key} ,field: 'imgFile' ,url: upload //,multiple: true ,before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。 layer.load(); //上传loading } ,done: function(data) { //var data = eval('('+res+')'); layer.closeAll('loading'); var l = $('.pics').length; if (l > 10) { layer.alert('请不要超过9张图片'); return; } html = '
  • '; e.before(html) close(); } ,error: function(){ //请求异常回调 } }); }); }