多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
>[warning] 使用前请务必在js页面引入**fselector.js imgpreview.js** #### 高拍仪上传组件 >[info] selectHardware: function (callback,options) {} * callback:文件上传后的回调函数 * options:初始化参数 >[success]回调函数 上传成功后的回调函数主要读取ret中的数据,ret返回数据格式如下: ```php { "code":1, "msg":"上传成功", "data": { "fileId":"1", "title":"1dcc5e90f603738d8a0c27ddbd1bb051fa19ecdc", "url":"\/uploads\/20190708\/3e72e1066f353e8da7caf7aeabfbb4f0.gif", "path":"\/uploads\/20190708\/3e72e1066f353e8da7caf7aeabfbb4f0.gif", "thumbPath":"\/uploads\/20190708\/3e72e1066f353e8da7caf7aeabfbb4f0.gif", "fullPath":"http:\/\/www.yun.com:8091\/uploads\/20190708\/3e72e1066f353e8da7caf7aeabfbb4f0.gif", "hash":"4ba48c37508019cdca6cf935f38cbac8ac59fdd0", "size":20971520, "type":"gif" }, "url":"", "wait":3 } } ``` >[success]示例代码 表单页面代码【说明:在高拍仪按钮中需要在class中添加uploadHardware data-list-box-id必须为imgpreview。同时需要添加一个显示文件内容的div,其id为imgpreview,class添加imgpreview_edit】 ```html <div class="form-group"> <label class="col-xs-12 col-sm-2 control-label">相关附件:</label> <div class="col-xs-12 col-sm-8"> <button type="button" id="btnUploaderWare" data-filetype="file" data-list-box-id="imgpreview" class="btn btn-info uploadHardware"><i class="fa fa-upload"></i> 高拍仪</button> </div> </div> <div class="form-group"> <ul class="col-xs-10 col-xs-offset-2 imgpreview_edit" id="imgpreview"> </ul> </div> ``` js页面代码 ```js Selector.api.selectHardware(function (data) { var listBoxId = $this.data('list-box-id'); var listBox = $('#' + listBoxId); listBox.data('imgview').add(data); },{}); ```