当前位置: 代码迷 >> 综合 >> layui upload; 限制上传个数打断提交
  详细解决方案

layui upload; 限制上传个数打断提交

热度:80   发布时间:2023-11-11 08:04:20.0

Before回调中使用stopPropagation(); 强行打断进程

layui.use('upload', function() {var upload = layui.upload;//执行实例var uploadInst = upload.render({elem: '#uploade', //绑定元素url: '/upload', //上传接口size: 1024 * 2,accept: 'images',acceptMime: 'image/jpg, image/png',before: function(res) {if(imglist.length>5){layer.msg("上传图片不能超过5张!", { icon: 2, offset: "auto", time: 3000 });stopPropagation();}},done: function(res) {//上传完毕回调console.log(res.data.url, "成功回调")imglist.push(res.data.url)},error: function() {//请求异常回调}});});

 

  相关解决方案