Rumah > Soal Jawab > teks badan
现在已经实现多图上传,但是不太清楚如何在修改时回显,模拟插件添加图片,但是模拟的方法有错,
var files=[{"id":"WU_FILE_0","name":"1478598670983.jpg","type":"image/jpg","size":1523,"url":"../uploadImg/1478598670983.jpg"},{"id":"WU_FILE_1","name":"1478598674559.jpg","type":"image/jpg","size":1523,"url":"../uploadImg/1478598674559.jpg"},{"id":"WU_FILE_2","name":"1478598677967.jpg","type":"image/jpg","size":1523,"url":"../uploadImg/1478598677967.jpg"}];
for(var i = 0; i < files.length; i++){
var obj ={};
statusMap = {};
fileCount++;
fileSize += files[i].size;
if ( fileCount === 1 ) {
placeholder.addClass( 'element-invisible' );
statusBar.show();
}
obj.id=files[i].id;
obj.name=files[i].name;
obj.type=files[i].type;
obj.size=files[i].size;
obj.ret=files[i].url;
obj.source=this;
obj.flog=true;
obj.status = 'complete',
obj.getStatus = function(){
return '';
}
obj.version = WebUploader.Base.version;
obj.statusText = '';
obj.setStatus = function(){
var prevStatus = statusMap[this.id];
typeof text !== 'undefined' && (this.statusText = text);
if(status !== prevStatus){
statusMap[this.id] = status;
//文件状态设置为已完成
uploader[index].trigger('statuschage',status,prevStatus);
}
}
addFile( obj,uploader[index],queue);
setState( 'ready' ,uploader[index],placeholder,queue,statusBar,jxfilePicker);
updateStatus('ready',info,fileCount,fileSize);
}
这样图片不会出现,只会有预览中三个字,感觉思路混乱,望指点
大家讲道理2017-04-11 10:07:47
//接收服务器返回信息
//这里才是接收服务器信息的地方,如果有出错就 `return false` 来停止上传
uploader.on( 'uploadAccept', function( file, response ) {
var str = response._raw;
var info = eval('(' + str + ')');
console.log(info);
//if ( hasError ) {
// // 通过return false来告诉组件,此文件上传有错。
// return false;
//}
});
服务器上传完就用它接收地址呗