kui-vue 3.2.4 → 3.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/_tool/utils.js +2 -2
- package/components/alert/styles/index.less +19 -19
- package/components/avatar/styles/index.less +3 -3
- package/components/backtop/styles/index.less +2 -2
- package/components/badge/demo/dot.md +1 -1
- package/components/badge/demo/dynamic.md +1 -1
- package/components/badge/demo/max.md +1 -1
- package/components/badge/styles/index.less +21 -21
- package/components/base/input.jsx +16 -10
- package/components/breadcrumb/styles/index.less +4 -4
- package/components/button/button.jsx +14 -8
- package/components/button/buttonGroup.jsx +6 -6
- package/components/button/demo/base.md +2 -1
- package/components/button/demo/disabled.md +14 -16
- package/components/button/demo/group.md +2 -2
- package/components/button/demo/index.vue +6 -2
- package/components/button/demo/light.md +26 -0
- package/components/button/demo/loading.md +1 -1
- package/components/button/demo/normal.md +25 -0
- package/components/button/demo/size.md +2 -2
- package/components/button/demo/solid.md +16 -0
- package/components/button/demo/with-icon.md +4 -3
- package/components/button/index.md +3 -3
- package/components/button/styles/index.less +106 -45
- package/components/card/demo/base.md +1 -1
- package/components/card/demo/border.md +2 -2
- package/components/card/styles/index.less +6 -6
- package/components/carousel/styles/index.less +1 -1
- package/components/checkbox/demo/group-vertical.md +47 -0
- package/components/checkbox/demo/index.vue +4 -0
- package/components/checkbox/demo/options.md +46 -0
- package/components/checkbox/group.jsx +9 -3
- package/components/checkbox/index.md +8 -7
- package/components/checkbox/styles/index.less +30 -20
- package/components/collapse/styles/index.less +10 -10
- package/components/colorPicker/styles/index.less +14 -14
- package/components/datePicker/datepicker.jsx +11 -3
- package/components/datePicker/demo/index.vue +2 -0
- package/components/datePicker/demo/theme.md +34 -0
- package/components/datePicker/index.md +4 -1
- package/components/datePicker/styles/calendar.less +39 -38
- package/components/datePicker/styles/datepicker.less +37 -20
- package/components/divider/styles/index.less +6 -6
- package/components/drawer/styles/index.less +12 -10
- package/components/dropdown/demo/base.md +4 -4
- package/components/dropdown/demo/cascading.md +3 -3
- package/components/dropdown/demo/divider.md +3 -3
- package/components/dropdown/styles/index.less +4 -4
- package/components/empty/styles/index.less +2 -2
- package/components/form/demo/base.md +25 -2
- package/components/form/demo/index.vue +1 -1
- package/components/form/demo/valid.md +9 -0
- package/components/form/form.jsx +2 -0
- package/components/form/formitem.jsx +18 -10
- package/components/form/styles/index.less +17 -13
- package/components/grid/styles/index.less +1 -1
- package/components/icon/demo/base.md +4 -4
- package/components/icon/demo/search.vue +6 -9
- package/components/image/styles/index.less +18 -18
- package/components/index.js +3 -1
- package/components/input/demo/index.vue +3 -1
- package/components/input/demo/theme.md +39 -0
- package/components/input/index.md +9 -6
- package/components/input/input.jsx +10 -3
- package/components/input/styles/index.less +120 -78
- package/components/input/textarea.jsx +1 -0
- package/components/layout/demo/base.md +5 -3
- package/components/layout/demo/index.vue +0 -2
- package/components/layout/demo/info.md +0 -2
- package/components/layout/demo/layout1.md +40 -47
- package/components/layout/demo/layout2.md +42 -49
- package/components/layout/demo/layout3.md +44 -22
- package/components/layout/demo/layout4.md +19 -18
- package/components/layout/demo/layout5.md +47 -44
- package/components/layout/styles/index.less +1 -6
- package/components/loading/styles/index.less +4 -4
- package/components/menu/demo/accrodion.md +2 -2
- package/components/menu/demo/base.md +5 -13
- package/components/menu/demo/collapsed.md +2 -2
- package/components/menu/demo/index.vue +0 -2
- package/components/menu/demo/inline.md +6 -10
- package/components/menu/demo/mode.md +2 -2
- package/components/menu/demo/theme.md +2 -2
- package/components/menu/demo/vertical.md +2 -2
- package/components/menu/index.md +0 -3
- package/components/menu/menu.jsx +4 -4
- package/components/menu/menuitem.jsx +1 -13
- package/components/menu/styles/dropmenu.less +28 -20
- package/components/menu/styles/index.less +148 -251
- package/components/menu/submenu.jsx +4 -64
- package/components/message/group.jsx +1 -1
- package/components/message/styles/index.less +13 -8
- package/components/modal/demo/base.md +15 -2
- package/components/modal/demo/custom.md +2 -2
- package/components/modal/demo/more.md +6 -6
- package/components/modal/modal.jsx +11 -5
- package/components/modal/styles/index.less +24 -17
- package/components/notice/styles/index.less +14 -13
- package/components/page/styles/index.less +16 -16
- package/components/popconfirm/styles/index.less +6 -6
- package/components/poptip/styles/index.less +10 -9
- package/components/progress/styles/index.less +13 -13
- package/components/radio/button.jsx +2 -2
- package/components/radio/demo/button.md +3 -3
- package/components/radio/demo/group-vertical.md +46 -0
- package/components/radio/demo/index.vue +4 -0
- package/components/radio/demo/options.md +43 -0
- package/components/radio/group.jsx +14 -8
- package/components/radio/index.md +11 -9
- package/components/radio/styles/index.less +33 -22
- package/components/rate/styles/index.less +2 -2
- package/components/select/demo/icon.md +40 -0
- package/components/select/demo/index.vue +4 -0
- package/components/select/demo/size.md +5 -5
- package/components/select/demo/theme.md +46 -0
- package/components/select/index.md +5 -2
- package/components/select/select.jsx +20 -13
- package/components/select/styles/index.less +113 -49
- package/components/slider/slider.jsx +9 -4
- package/components/slider/styles/index.less +7 -7
- package/components/space/demo/align.md +1 -1
- package/components/spin/styles/index.less +7 -11
- package/components/steps/styles/index.less +11 -11
- package/components/styles/color.less +158 -0
- package/components/styles/index.less +3 -1
- package/components/styles/sys.less +34 -0
- package/components/styles/var.less +150 -0
- package/components/switch/styles/index.less +11 -11
- package/components/table/styles/index.less +29 -32
- package/components/tabs/styles/index.less +20 -19
- package/components/tag/styles/index.less +45 -45
- package/components/timeline/styles/index.less +5 -5
- package/components/tooltip/styles/index.less +19 -18
- package/components/tree/styles/index.less +15 -15
- package/components/treeselect/styles/index.less +5 -5
- package/components/upload/demo/accept.md +68 -0
- package/components/upload/demo/avatar.md +40 -0
- package/components/upload/demo/base.md +40 -0
- package/components/upload/demo/custom.md +47 -0
- package/components/upload/demo/directory.md +36 -0
- package/components/upload/demo/drag.md +0 -0
- package/components/upload/demo/draggable.md +45 -0
- package/components/upload/demo/exceed.md +42 -0
- package/components/upload/demo/file-list.md +42 -0
- package/components/upload/demo/form.md +120 -0
- package/components/upload/demo/index.vue +37 -0
- package/components/upload/demo/info.md +10 -0
- package/components/upload/demo/picture.md +54 -0
- package/components/upload/index.md +26 -0
- package/components/upload/styles/index.less +258 -0
- package/components/upload/upload.jsx +336 -0
- package/dist/k-ui.css +1 -1
- package/dist/k-ui.js +2 -2
- package/package.json +9 -4
- package/components/button/demo/hollow.md +0 -15
- package/components/layout/demo/layout6.md +0 -142
- package/components/menu/demo/vertical-affix.md +0 -69
- package/components/styles/dark.less +0 -70
- package/components/styles/global-dark.less +0 -36
- package/components/styles/global.less +0 -44
- package/components/upload/upload.vue +0 -137
- package/dist/k-ui-dark.css +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<cn>
|
|
2
|
+
#### 点击上传
|
|
3
|
+
经典款式,用户点击按钮弹出文件选择框。
|
|
4
|
+
</cn>
|
|
5
|
+
|
|
6
|
+
```vue
|
|
7
|
+
<template>
|
|
8
|
+
<Upload
|
|
9
|
+
action="https://run.mocky.io/v3/79c1cb9d-040a-43d9-919d-91ded176a9c2"
|
|
10
|
+
name="file"
|
|
11
|
+
:headers="headers"
|
|
12
|
+
@change="handleChange"
|
|
13
|
+
>
|
|
14
|
+
<Button icon="cloud-upload-outline">Click to upload</Button>
|
|
15
|
+
</Upload>
|
|
16
|
+
</template>
|
|
17
|
+
<script>
|
|
18
|
+
export default{
|
|
19
|
+
data(){
|
|
20
|
+
return {
|
|
21
|
+
headers:{
|
|
22
|
+
authorization: 'here is token'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
methods:{
|
|
27
|
+
handleChange(info){
|
|
28
|
+
if (info.file.status !== 'uploading') {
|
|
29
|
+
console.log(info.file, info.fileList);
|
|
30
|
+
}
|
|
31
|
+
if (info.file.status === 'success') {
|
|
32
|
+
this.$Message.success(`${info.file.filename} uploaded successfully`);
|
|
33
|
+
} else if (info.file.status === 'error') {
|
|
34
|
+
this.$Message.error(`${info.file.filename} upload failed.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<cn>
|
|
2
|
+
#### 手动上传/自定义属性
|
|
3
|
+
- 通过设置 data、headers 可添加自定义上传属性
|
|
4
|
+
- autoTrigger='false',选中文件后将不会自动触发上传。需要手动调用 ref 上的 upload 方法触发
|
|
5
|
+
- name 为上传文件名
|
|
6
|
+
</cn>
|
|
7
|
+
|
|
8
|
+
```vue
|
|
9
|
+
<template>
|
|
10
|
+
<Upload
|
|
11
|
+
action="https://run.mocky.io/v3/79c1cb9d-040a-43d9-919d-91ded176a9c2"
|
|
12
|
+
name="file"
|
|
13
|
+
:headers="headers"
|
|
14
|
+
:data="pramas"
|
|
15
|
+
:autoTrigger="false"
|
|
16
|
+
@before-upload="beforeUpload"
|
|
17
|
+
@remove="beforeUpload"
|
|
18
|
+
multiple
|
|
19
|
+
ref="upload"
|
|
20
|
+
>
|
|
21
|
+
<Button icon="cloud-upload-outline" >点击选择上传文件</Button>
|
|
22
|
+
</Upload>
|
|
23
|
+
<br/>
|
|
24
|
+
<Button :disabled="disabled" @click="$refs.upload.upload()">开始上传</Button>
|
|
25
|
+
</template>
|
|
26
|
+
<script>
|
|
27
|
+
export default{
|
|
28
|
+
data(){
|
|
29
|
+
return {
|
|
30
|
+
pramas:{
|
|
31
|
+
type:'image',
|
|
32
|
+
time: Date.now()
|
|
33
|
+
},
|
|
34
|
+
headers:{
|
|
35
|
+
authorization: 'here is token'
|
|
36
|
+
},
|
|
37
|
+
disabled:true,
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
methods:{
|
|
41
|
+
beforeUpload(info){
|
|
42
|
+
this.disabled = info.fileList.length == 0
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
</script>
|
|
47
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<cn>
|
|
2
|
+
#### 上传文件夹
|
|
3
|
+
通过传入 directory 为 true,可以支持上传文件夹下的所有文件
|
|
4
|
+
</cn>
|
|
5
|
+
|
|
6
|
+
```vue
|
|
7
|
+
<template>
|
|
8
|
+
<Upload
|
|
9
|
+
action="https://run.mocky.io/v3/79c1cb9d-040a-43d9-919d-91ded176a9c2"
|
|
10
|
+
name="file"
|
|
11
|
+
directory
|
|
12
|
+
:headers="headers"
|
|
13
|
+
@change="handleChange"
|
|
14
|
+
>
|
|
15
|
+
<Button icon="cloud-upload-outline">Click to upload</Button>
|
|
16
|
+
</Upload>
|
|
17
|
+
</template>
|
|
18
|
+
<script>
|
|
19
|
+
export default{
|
|
20
|
+
data(){
|
|
21
|
+
return {
|
|
22
|
+
headers:{
|
|
23
|
+
authorization: 'here is token'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
methods:{
|
|
28
|
+
handleChange(info){
|
|
29
|
+
if (info.file.status !== 'uploading') {
|
|
30
|
+
console.log(info.file, info.fileList);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
```
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<cn>
|
|
2
|
+
#### 拖拽上传
|
|
3
|
+
draggable='true',可以使用拖拽功能
|
|
4
|
+
</cn>
|
|
5
|
+
|
|
6
|
+
```vue
|
|
7
|
+
<template>
|
|
8
|
+
<div style="width:556px">
|
|
9
|
+
<Upload
|
|
10
|
+
action="https://run.mocky.io/v3/79c1cb9d-040a-43d9-919d-91ded176a9c2"
|
|
11
|
+
name="file"
|
|
12
|
+
:headers="headers"
|
|
13
|
+
draggable
|
|
14
|
+
uploadIcon="cloud-upload-outline"
|
|
15
|
+
uploadText="点击上传文件或拖拽文件到这里"
|
|
16
|
+
uploadSubText="支持任意类型文件"
|
|
17
|
+
@change="handleChange"
|
|
18
|
+
>
|
|
19
|
+
</Upload>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
<script>
|
|
23
|
+
export default{
|
|
24
|
+
data(){
|
|
25
|
+
return {
|
|
26
|
+
headers:{
|
|
27
|
+
authorization: 'here is token'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
methods:{
|
|
32
|
+
handleChange(info){
|
|
33
|
+
if (info.file.status !== 'uploading') {
|
|
34
|
+
console.log(info.file, info.fileList);
|
|
35
|
+
}
|
|
36
|
+
if (info.file.status === 'success') {
|
|
37
|
+
this.$Message.success(`${info.file.filename} uploaded successfully`);
|
|
38
|
+
} else if (info.file.status === 'error') {
|
|
39
|
+
this.$Message.error(`${info.file.filename} upload failed.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<cn>
|
|
2
|
+
#### 上传限制
|
|
3
|
+
limit 限制上传数量, minSize 和 maxSize 属性可以自定义上传文件大小的限制。
|
|
4
|
+
</cn>
|
|
5
|
+
|
|
6
|
+
```vue
|
|
7
|
+
<template>
|
|
8
|
+
<Upload
|
|
9
|
+
action="https://run.mocky.io/v3/79c1cb9d-040a-43d9-919d-91ded176a9c2"
|
|
10
|
+
name="file"
|
|
11
|
+
:headers="headers"
|
|
12
|
+
:limit="limit"
|
|
13
|
+
:minSize="200"
|
|
14
|
+
:maxSize="1024"
|
|
15
|
+
@exceed="()=>{ this.$Message.warning(`最多只能上传${limit}个文件`) }"
|
|
16
|
+
@size-error="({file})=>{ this.$Message.warning(`${file.filename}大小超过限制`) }"
|
|
17
|
+
@change="handleChange"
|
|
18
|
+
@remove="handleChange"
|
|
19
|
+
multiple
|
|
20
|
+
>
|
|
21
|
+
<Button icon="cloud-upload-outline" :disabled="disabled">点击上传 (最小200KB, 最大1MB,最多上传 {{limit}} 项)</Button>
|
|
22
|
+
</Upload>
|
|
23
|
+
</template>
|
|
24
|
+
<script>
|
|
25
|
+
export default{
|
|
26
|
+
data(){
|
|
27
|
+
return {
|
|
28
|
+
headers:{
|
|
29
|
+
authorization: 'here is token'
|
|
30
|
+
},
|
|
31
|
+
disabled:false,
|
|
32
|
+
limit:2,
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
methods:{
|
|
36
|
+
handleChange(info){
|
|
37
|
+
this.disabled = info.fileList.length >= this.limit
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<cn>
|
|
2
|
+
#### 上传多个文件
|
|
3
|
+
通过设置 multiple 属性可以支持同时选中多个文件上传。
|
|
4
|
+
>不设置为默认, 只能上传一个文件
|
|
5
|
+
</cn>
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<Upload
|
|
10
|
+
action="https://run.mocky.io/v3/79c1cb9d-040a-43d9-919d-91ded176a9c2"
|
|
11
|
+
name="file"
|
|
12
|
+
:headers="headers"
|
|
13
|
+
@change="handleChange"
|
|
14
|
+
multiple
|
|
15
|
+
>
|
|
16
|
+
<Button icon="cloud-upload-outline">Click to upload</Button>
|
|
17
|
+
</Upload>
|
|
18
|
+
</template>
|
|
19
|
+
<script>
|
|
20
|
+
export default{
|
|
21
|
+
data(){
|
|
22
|
+
return {
|
|
23
|
+
headers:{
|
|
24
|
+
authorization: 'here is token'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
methods:{
|
|
29
|
+
handleChange(info){
|
|
30
|
+
if (info.file.status !== 'uploading') {
|
|
31
|
+
console.log(info.file, info.fileList);
|
|
32
|
+
}
|
|
33
|
+
if (info.file.status === 'success') {
|
|
34
|
+
this.$Message.success(`${info.file.filename} uploaded successfully`);
|
|
35
|
+
} else if (info.file.status === 'error') {
|
|
36
|
+
this.$Message.error(`${info.file.filename} upload failed.`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
```
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
|
|
2
|
+
<cn>
|
|
3
|
+
#### 表单校验
|
|
4
|
+
上传表单校验
|
|
5
|
+
</cn>
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<Form :model="form" :rules="rules" @submit="submit" :wrapperCol="wrapperCol" :labelCol="labelCol" ref="form">
|
|
10
|
+
<FormItem label="图像" prop="avatar">
|
|
11
|
+
<Upload
|
|
12
|
+
action="https://run.mocky.io/v3/79c1cb9d-040a-43d9-919d-91ded176a9c2"
|
|
13
|
+
name="file"
|
|
14
|
+
type="picture"
|
|
15
|
+
:headers="headers"
|
|
16
|
+
@change="uploadAvatar"
|
|
17
|
+
@remove="()=>form.avatar=''"
|
|
18
|
+
:limit="1"
|
|
19
|
+
accept="image/*"
|
|
20
|
+
uploadIcon="camera-outline"
|
|
21
|
+
uploadText="上传头像"
|
|
22
|
+
>
|
|
23
|
+
</Upload>
|
|
24
|
+
<Input type="hidden"/>
|
|
25
|
+
</FormItem>
|
|
26
|
+
<FormItem label="单个文件" prop="file">
|
|
27
|
+
<Input readonly placeholder="请上传文件">
|
|
28
|
+
<Upload
|
|
29
|
+
action="https://run.mocky.io/v3/79c1cb9d-040a-43d9-919d-91ded176a9c2"
|
|
30
|
+
name="file"
|
|
31
|
+
:headers="headers"
|
|
32
|
+
@change="uploadFile"
|
|
33
|
+
@remove="()=>form.file=''"
|
|
34
|
+
:showUploadList="false"
|
|
35
|
+
:limit="1"
|
|
36
|
+
accept="image/*"
|
|
37
|
+
slot="suffix"
|
|
38
|
+
><Icon type="cloud-upload-outline" size="20" /></Upload>
|
|
39
|
+
</Input>
|
|
40
|
+
</FormItem>
|
|
41
|
+
<FormItem label="多个文件" prop="files">
|
|
42
|
+
<Upload
|
|
43
|
+
action="https://run.mocky.io/v3/79c1cb9d-040a-43d9-919d-91ded176a9c2"
|
|
44
|
+
name="file"
|
|
45
|
+
:headers="headers"
|
|
46
|
+
@change="uploadFiles"
|
|
47
|
+
@remove="remove"
|
|
48
|
+
accept="image/*"
|
|
49
|
+
><Button theme="light">上传文件</Button>
|
|
50
|
+
</Upload>
|
|
51
|
+
<Input type="hidden"/>
|
|
52
|
+
</FormItem>
|
|
53
|
+
<FormItem :wrapperCol="{offset:6}">
|
|
54
|
+
<Button type="primary" htmlType="submit">提交表单</Button>
|
|
55
|
+
</FormItem>
|
|
56
|
+
<Form>
|
|
57
|
+
</template>
|
|
58
|
+
<script>
|
|
59
|
+
export default{
|
|
60
|
+
data(){
|
|
61
|
+
return {
|
|
62
|
+
labelCol: { span: 6 },
|
|
63
|
+
wrapperCol: { span: 16 },
|
|
64
|
+
headers:{
|
|
65
|
+
authorization: 'here is token'
|
|
66
|
+
},
|
|
67
|
+
form:{
|
|
68
|
+
avatar:'',
|
|
69
|
+
file:'',
|
|
70
|
+
files:[],
|
|
71
|
+
},
|
|
72
|
+
rules: {
|
|
73
|
+
avatar: [
|
|
74
|
+
{ required: true, message: '请上传图像' },
|
|
75
|
+
],
|
|
76
|
+
file: [
|
|
77
|
+
{ required: true, message: '请上传文件' },
|
|
78
|
+
],
|
|
79
|
+
files: [
|
|
80
|
+
{ required: true, message: '请上传文件' },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
methods:{
|
|
86
|
+
uploadFile({file}){
|
|
87
|
+
if (file.status == 'success') {
|
|
88
|
+
this.form.file = file.response.url
|
|
89
|
+
this.$refs.form.test('file')
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
uploadFiles({file}){
|
|
93
|
+
if (file.status == 'success') {
|
|
94
|
+
this.form.files.push(file.response.url)
|
|
95
|
+
this.$refs.form.test('files')
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
remove({file}){
|
|
99
|
+
// 删除文件的时候 要对应的从表单中删除相对应的url
|
|
100
|
+
if(file.status == 'success'){
|
|
101
|
+
let url = file.response.url
|
|
102
|
+
let index = this.form.files.indexOf(url)
|
|
103
|
+
this.form.files.slice(index,1)
|
|
104
|
+
this.$refs.form.test('files')
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
uploadAvatar({file}){
|
|
108
|
+
if (file.status == 'success') {
|
|
109
|
+
this.form.avatar = file.response.url
|
|
110
|
+
this.$refs.form.test('avatar')
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
submit({valid, model}) {
|
|
114
|
+
this.$Message[valid ? 'success' : 'error'](valid ? 'success' : 'faild')
|
|
115
|
+
console.log(model)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
</script>
|
|
120
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Info from './info'
|
|
3
|
+
import Base from './base'
|
|
4
|
+
import FileList from './file-list'
|
|
5
|
+
import Accept from './accept'
|
|
6
|
+
import Exceed from './exceed'
|
|
7
|
+
import Custom from './custom'
|
|
8
|
+
import Directory from './directory'
|
|
9
|
+
import Picture from './picture'
|
|
10
|
+
import Avatar from './avatar'
|
|
11
|
+
import Draggable from './draggable'
|
|
12
|
+
import Form from './form'
|
|
13
|
+
|
|
14
|
+
import CN from '../index.md'
|
|
15
|
+
export default {
|
|
16
|
+
render() {
|
|
17
|
+
return (
|
|
18
|
+
<div class="switch-demo">
|
|
19
|
+
<Info class="typo" />
|
|
20
|
+
<Base />
|
|
21
|
+
<FileList />
|
|
22
|
+
<Directory />
|
|
23
|
+
<Accept />
|
|
24
|
+
<Exceed />
|
|
25
|
+
<Custom />
|
|
26
|
+
<Picture />
|
|
27
|
+
<Avatar />
|
|
28
|
+
<Draggable/>
|
|
29
|
+
<Form />
|
|
30
|
+
<CN class="typo" />
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
</script>
|
|
37
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<cn>
|
|
2
|
+
#### 照片墙
|
|
3
|
+
设置 type = 'picture',用户可以上传图片并在列表中显示缩略图
|
|
4
|
+
</cn>
|
|
5
|
+
|
|
6
|
+
```vue
|
|
7
|
+
<template>
|
|
8
|
+
<Upload
|
|
9
|
+
action="https://run.mocky.io/v3/79c1cb9d-040a-43d9-919d-91ded176a9c2"
|
|
10
|
+
name="file"
|
|
11
|
+
type="picture"
|
|
12
|
+
:headers="headers"
|
|
13
|
+
@change="handleChange"
|
|
14
|
+
:fileList="fileList"
|
|
15
|
+
accept="image/*"
|
|
16
|
+
uploadText="上传图片"
|
|
17
|
+
>
|
|
18
|
+
</Upload>
|
|
19
|
+
</template>
|
|
20
|
+
<script>
|
|
21
|
+
export default{
|
|
22
|
+
data(){
|
|
23
|
+
return {
|
|
24
|
+
headers:{
|
|
25
|
+
authorization: 'here is token'
|
|
26
|
+
},
|
|
27
|
+
fileList:[
|
|
28
|
+
{
|
|
29
|
+
url:'https://www.chuchur.com/upload/demo/test_300.jpg',
|
|
30
|
+
status:'uploading',
|
|
31
|
+
filename:'test.jpg',
|
|
32
|
+
size:'222kb',
|
|
33
|
+
percent:50,
|
|
34
|
+
status:'uploading'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
url:'https://www.chuchur.com/upload/demo/test_300.jpg',
|
|
38
|
+
status:'error',
|
|
39
|
+
filename:'test.jpg',
|
|
40
|
+
size:'222kb'
|
|
41
|
+
},
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
methods:{
|
|
46
|
+
handleChange(info){
|
|
47
|
+
if (info.file.status !== 'uploading') {
|
|
48
|
+
console.log(info.file, info.fileList);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
## Upload API
|
|
2
|
+
|
|
3
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
4
|
+
| -------------- | ------------------------------------------------------------------------------------------------------------------------------ | -------------- | ------ |
|
|
5
|
+
| accept | 接受上传的文件类型, 详见 [input accept Attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept) | String | - |
|
|
6
|
+
| action | 上传的地址 | String | - |
|
|
7
|
+
| method | 上传请求的 http method | String | post |
|
|
8
|
+
| data | 上传所需参数 | Object | - |
|
|
9
|
+
| disabled | 是否禁用 | Boolean | false |
|
|
10
|
+
| headers | 设置上传的请求头部 | Object | - |
|
|
11
|
+
| multiple | 是否支持多选文件 | Boolean | false |
|
|
12
|
+
| directory | 是否支持上传目录 | Boolean | false |
|
|
13
|
+
| showUploadList | 是否显示上传列表 | Boolean | true |
|
|
14
|
+
| autoTrigger | 是否自动上传 | Boolean | true |
|
|
15
|
+
| draggable | 是否支持拖拽上传 | Boolean | false |
|
|
16
|
+
| fileList | 上传的文件列表 | Array | false |
|
|
17
|
+
| name | 发到后台的文件参数名 | String | 'file' |
|
|
18
|
+
| uploadIcon | 上传域的辅助图标 | String | 'file' |
|
|
19
|
+
| uploadText | 上传域的辅助文字 | String | 'file' |
|
|
20
|
+
| uploadSubText | 上传域的二级辅助文字 | String | 'file' |
|
|
21
|
+
| limit | 最多允许上传文件个数 | Number | - |
|
|
22
|
+
| minSize | 上传文件最小单位(KB) | String | - |
|
|
23
|
+
| maxSize | 上传文件最大单位(KB) | String | - |
|
|
24
|
+
| transformFile | 在上传之前转换文件。支持返回一个 Promise 对象 | Function(file) | - |
|
|
25
|
+
| change | 上传中、完成、失败都会调用这个函数 | Function | - |
|
|
26
|
+
| remove | 移除文件 | Function | - |
|