From 461e5edbfdcee76fc939fe061db49e50e6c67083 Mon Sep 17 00:00:00 2001 From: baiyaaaaa Date: Sat, 31 Dec 2016 13:10:46 +0800 Subject: [PATCH] upload rename defaultFileList to fileList --- examples/docs/zh-CN/upload.md | 8 ++++---- packages/upload/src/index.vue | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/docs/zh-CN/upload.md b/examples/docs/zh-CN/upload.md index 76929656..c81cc422 100644 --- a/examples/docs/zh-CN/upload.md +++ b/examples/docs/zh-CN/upload.md @@ -54,7 +54,7 @@ action="//jsonplaceholder.typicode.com/posts/" :on-preview="handlePreview" :on-remove="handleRemove" - :default-file-list="fileList"> + :file-list="fileList"> 点击上传
只能上传jpg/png文件,且不超过500kb
@@ -92,7 +92,7 @@ :on-remove="handleRemove" :on-success="handleSuccess" :on-error="handleError" - :default-file-list="fileList" + :file-list="fileList" >
将文件拖到此处,或点击上传
@@ -130,7 +130,7 @@ :thumbnail-mode="true" :on-preview="handlePreview" :on-remove="handleRemove" - :default-file-list="fileList" + :file-list="fileList" >
将文件拖到此处,或点击上传
@@ -175,7 +175,7 @@ | on-progress | 可选参数, 文件上传时的钩子 | function(event, file, fileList) | — | — | | before-upload | 可选参数, 上传文件之前的钩子,参数为上传的文件,若返回 false 或者 Promise 则停止上传。 | function(file) | — | — | | thumbnail-mode | 是否设置为图片模式,该模式下会显示图片缩略图 | boolean | — | false | -| default-file-list | 默认已上传的文件列表, 例如: [{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}] | array | — | [] | +| fileList | 默认已上传的文件列表, 例如: [{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}] | array | — | [] | ### Methods | 方法名 | 说明 | 参数 | diff --git a/packages/upload/src/index.vue b/packages/upload/src/index.vue index d6c22ed4..5dbe755f 100644 --- a/packages/upload/src/index.vue +++ b/packages/upload/src/index.vue @@ -70,7 +70,7 @@ export default { type: Function, default: noop }, - defaultFileList: { + fileList: { type: Array, default() { return []; @@ -80,7 +80,7 @@ export default { data() { return { - fileList: [], + _fileList: [], dragOver: false, draging: false, tempIndex: 1 @@ -88,10 +88,10 @@ export default { }, watch: { - defaultFileList: { + fileList: { immediate: true, handler(fileList) { - this.fileList = fileList.map(item => { + this._fileList = fileList.map(item => { item.status = 'finished'; item.percentage = 100; item.uid = Date.now() + this.tempIndex++; @@ -120,11 +120,11 @@ export default { return; } - this.fileList.push(_file); + this._fileList.push(_file); }, handleProgress(ev, file) { var _file = this.getFile(file); - this.onProgress(ev, _file, this.fileList); + this.onProgress(ev, _file, this._fileList); _file.percentage = ev.percent || 0; }, handleSuccess(res, file) { @@ -134,7 +134,7 @@ export default { _file.status = 'finished'; _file.response = res; - this.onSuccess(res, _file, this.fileList); + this.onSuccess(res, _file, this._fileList); setTimeout(() => { _file.showProgress = false; @@ -143,7 +143,7 @@ export default { }, handleError(err, response, file) { var _file = this.getFile(file); - var fileList = this.fileList; + var fileList = this._fileList; _file.status = 'fail'; @@ -152,12 +152,12 @@ export default { this.onError(err, response, file); }, handleRemove(file) { - var fileList = this.fileList; + var fileList = this._fileList; fileList.splice(fileList.indexOf(file), 1); this.onRemove(file, fileList); }, getFile(file) { - var fileList = this.fileList; + var fileList = this._fileList; var target; fileList.every(item => { target = file.uid === item.uid ? item : null; @@ -171,7 +171,7 @@ export default { } }, clearFiles() { - this.fileList = []; + this._fileList = []; } },