前提 使用layer之前确保,自己文件layer的js,css 都已经引用
<img src="${_fileUrl}/${o.img!}" id="imgUrl" class="l-logo-img01">
<button type="button" class="layui-btn layui-btn-primary layui-btn-lw mar-t-10" id="btnUploadFile">
<i class="layui-icon"></i>上传图片
</button>
layui.use('upload', function(){
var upload = layui.upload;
//执行实例
var uploadInst = upload.render({
elem: '#btnUploadFile' //绑定元素
,url: basePath+'/upload' //上传接口
,done: function(res){
//上传完毕回调
$("#imgUrl").attr("src","${_fileUrl}/"+res.data);
}
,error: function(){
//请求异常回调
}
});
});