多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
css ``` .uploadimg { width:200px; height:120px; margin: 5px; border-radius: 3px; background: lightblue; text-align: center; font-weight: 400; font-size: 15px; color:#fff } .uploadimg:after { content:"请上传文件"; line-height: 120px; } ``` html ``` <img src="/static/image/uploadimg.png" class="uploadimg" id="ceo_img" alt=""> ``` js ``` layui.use(['jquery', 'upload'], function () { $ = layui.jquery; //执行实例 var uploadInst = layui.upload.render({ elem: '.uploadimg', url: "{:url('api/common/upload')}", //上传接口 done: function (res) { // 给此img设置src属性 $(this.item).attr('src', res.data.src); }, error: function () { layer.msg('上传文件失败'); } }); }); ``` > 获取图片地址 `$('#ceo_img').attr('src');`