-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathfile-picker.vue
117 lines (109 loc) · 3.29 KB
/
file-picker.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<template>
<view class="container">
<uni-card :is-shadow="false" is-full>
<text class="uni-h6">文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间。</text>
</uni-card>
<uni-section title="只选择图片" type="line">
<view class="example-body">
<uni-file-picker limit="9" title="最多选择9张图片" :source-type="sourceType"></uni-file-picker>
</view>
</uni-section>
<uni-section title="只选择视频" type="line">
<view class="example-body">
<uni-file-picker limit="9" file-mediatype="video" title="最多选择9个视频" :source-type="sourceType"></uni-file-picker>
</view>
</uni-section>
<uni-section title="自定义图片和视频选择的来源" type="line">
<view class="example-body">
<uni-file-picker limit="9" title="从相册选图" :source-type="['album']"></uni-file-picker>
</view>
<view class="example-body">
<uni-file-picker limit="9" title="使用相机" file-mediatype="video" :source-type="['camera']"></uni-file-picker>
</view>
</uni-section>
<!-- #ifdef H5 || MP-WEIXIN -->
<uni-section title="选择任意文件" type="line">
<view class="example-body">
<uni-file-picker limit="5" file-mediatype="all" title="最多选择5个文件"></uni-file-picker>
</view>
</uni-section>
<!-- #endif -->
<uni-section title="自定义图片大小" type="line">
<view class="example-body custom-image-box">
<text class="text">选择头像</text>
<uni-file-picker limit="1" :del-icon="false" disable-preview :imageStyles="imageStyles"
file-mediatype="image">选择</uni-file-picker>
</view>
</uni-section>
<uni-section title="自定义图片大小" type="line">
<view class="example-body ">
<uni-file-picker readonly v-model="fileLists" :imageStyles="imageStyles" file-mediatype="image">
</uni-file-picker>
<uni-file-picker readonly v-model="fileLists" :listStyles="listStyles" file-mediatype="all">
</uni-file-picker>
</view>
</uni-section>
</view>
</template>
<script>
export default {
data() {
return {
sourceType: ['album', 'camera'],
imageStyles: {
width: 64,
height: 64,
border: {
radius: '50%'
}
},
listStyles: {
// 是否显示边框
border: true,
// 是否显示分隔线
dividline: true,
// 线条样式
borderStyle: {
width: 1,
color: 'blue',
style: 'dashed',
radius: 2
}
},
fileLists: [{
url: 'https://web-assets.dcloud.net.cn/unidoc/zh/shuijiao-small.jpg',
extname: 'png',
name: 'shuijiao.png'
}, {
url: 'https://web-assets.dcloud.net.cn/unidoc/zh/shuijiao-small.jpg',
extname: 'png',
name: 'uniapp-logo.png'
}, {
url: 'https://web-assets.dcloud.net.cn/unidoc/zh/shuijiao-small.jpg',
extname: 'png',
name: 'shuijiao.png'
}]
}
},
methods: {
}
}
</script>
<style lang="scss">
.example-body {
padding: 10px;
padding-top: 0;
}
.custom-image-box {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.text {
font-size: 14px;
color: #333;
}
</style>