[Doc] Uploader: update demo

This commit is contained in:
陈嘉涵
2019-06-04 16:02:36 +08:00
parent 076eb1c601
commit af4dea96ed
6 changed files with 16 additions and 32 deletions
+6 -6
View File
@@ -33,7 +33,7 @@ export default sfc({
data() {
return {
previewImages: []
uploadedFiles: []
};
},
@@ -61,7 +61,7 @@ export default sfc({
}
if (Array.isArray(files)) {
const maxCount = this.maxCount - this.previewImages.length;
const maxCount = this.maxCount - this.uploadedFiles.length;
files = files.slice(0, maxCount);
Promise.all(files.map(this.readFile)).then(contents => {
@@ -122,7 +122,7 @@ export default sfc({
},
addPreviewImage(file) {
this.previewImages.push(file.content);
this.uploadedFiles.push(file);
},
resetInput() {
@@ -134,14 +134,14 @@ export default sfc({
renderPreview() {
if (this.preview) {
return this.previewImages.map(image => (
<Image fit="cover" class={bem('preview')} src={image} />
return this.uploadedFiles.map(file => (
<Image fit="cover" class={bem('preview')} src={file.content} />
));
}
},
renderUpload() {
if (this.previewImages.length >= this.maxCount) {
if (this.uploadedFiles.length >= this.maxCount) {
return;
}