自定义使用Layui弹框
layui.use('upload', function() {
var $ = layui.jquery,
upload = layui.upload;
var flag = false;
var uploadInst = upload.render({
elem: '#provex',
url: '/upload/',
auto: true,
acceptMime: 'image/*',
exts:'jpg|png|gif|bmp|jpeg',
before: function(obj){
//预读本地文件示例,不支持ie8
obj.preview(function(index, file, result){
$('#provex').children().attr('src', result); //图片链接(base64)
});
flag = false;
},
done: function(res) {
$.toast("上传成功", "text");
flag = true;
},
error: function() {
flag = true;
}
});
$("#next").click(function() {
if (!flag){
$.toast("请上传文件", "text");
} else{
window.location.href = "";
$.toast("提交成功", "text");
}
})
});
layui的弹窗实例以及方法,不过用之前要引入layui的框架