Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit 1cf72f8

Browse files
committed
bug: UID问题
1 parent 4ea74c7 commit 1cf72f8

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

example/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
:isShowSize="true"
1111
:isShowTip="true"
1212
:limit="6"
13-
:multiple="false"
13+
:multiple="true"
1414
:responseFn="handleResponse"
1515
action="https://jsonplaceholder.typicode.com/posts/"
1616
placeholder="上传附件"

lib/EleUploadFile.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,18 @@ export default {
156156
},
157157
// 列表
158158
list () {
159+
let temp = 1
159160
if (this.value) {
160161
// 首先将值转为数组
161162
const list = Array.isArray(this.value) ? this.value : [this.value]
162163
// 然后将数组转为对象数组
163-
return list.map((item) => typeof item === 'string' ? { name: item, url: item } : item)
164+
return list.map((item) => {
165+
if (typeof item === 'string') {
166+
item = { name: item, url: item }
167+
}
168+
item.uid = item.uid || new Date() + temp++
169+
return item
170+
})
164171
} else {
165172
return []
166173
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-ele-upload-file",
33
"description": "对 element-ui upload 组件进一步封装, 使其更简单、易用",
4-
"version": "0.0.1",
4+
"version": "0.0.2",
55
"private": false,
66
"license": "MIT",
77
"scripts": {

0 commit comments

Comments
 (0)