Skip to content

Commit 25adaf6

Browse files
committed
update(doc): upload add custom case
1 parent cc1d492 commit 25adaf6

File tree

1 file changed

+86
-3
lines changed

1 file changed

+86
-3
lines changed

document/components/docs/en-US/upload.md

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@
5454

5555
```html
5656
<cube-upload
57-
ref="upload2"
58-
:action="action2"
57+
ref="upload"
58+
:action="action"
5959
:simultaneous-uploads="1"
6060
:process-file="processFile"
6161
@file-submitted="fileSubmitted"></cube-upload>
6262
```
6363
```js
64-
import compress from '../modules/image'
64+
import compress from '../../modules/image'
6565
export default {
6666
data() {
6767
return {
@@ -94,6 +94,89 @@
9494

9595
The `file-submitted` event will be trigged after the file is processed and added to the `upload.files` with a parameter -- the file object.
9696

97+
- Use slots
98+
99+
You can use slots to define your custom HTML structure.
100+
101+
```html
102+
<cube-upload
103+
ref="upload"
104+
v-model="files"
105+
:action="action"
106+
@files-added="addedHandler"
107+
@file-error="errHandler">
108+
<div class="clear-fix">
109+
<cube-upload-file v-for="(file, i) in files" :file="file" :key="i"></cube-upload-file>
110+
<cube-upload-btn :multiple="false">
111+
<div>
112+
<i>+</i>
113+
<p>Please click to upload ID card</p>
114+
</div>
115+
</cube-upload-btn>
116+
</div>
117+
</cube-upload>
118+
```
119+
```js
120+
export default {
121+
data() {
122+
return {
123+
action: '//jsonplaceholder.typicode.com/photos/',
124+
files: []
125+
}
126+
},
127+
methods: {
128+
addedHandler() {
129+
const file = this.files[0]
130+
file && this.$refs.upload.removeFile(file)
131+
},
132+
errHandler(file) {
133+
// const msg = file.response.message
134+
this.$createToast({
135+
type: 'warn',
136+
txt: 'Upload fail',
137+
time: 1000
138+
}).show()
139+
}
140+
}
141+
}
142+
```
143+
Custom Style:
144+
```stylus
145+
.cube-upload
146+
.cube-upload-file, .cube-upload-btn
147+
margin: 0
148+
height: 200px
149+
.cube-upload-file
150+
margin: 0
151+
+ .cube-upload-btn
152+
margin-top: -200px
153+
opacity: 0
154+
.cube-upload-file-def
155+
width: 100%
156+
height: 100%
157+
.cubeic-wrong
158+
display: none
159+
.cube-upload-btn
160+
display: flex
161+
align-items: center
162+
justify-content: center
163+
> div
164+
text-align: center
165+
i
166+
display: inline-flex
167+
align-items: center
168+
justify-content: center
169+
width: 50px
170+
height: 50px
171+
margin-bottom: 20px
172+
font-size: 32px
173+
line-height: 1
174+
font-style: normal
175+
color: #fff
176+
background-color: #333
177+
border-radius: 50%
178+
```
179+
97180
### Props configuration
98181

99182
| Attribute | Description | Type | Accepted Values | Demo |

0 commit comments

Comments
 (0)