file-picker.vue
2.78 KB
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
<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张图片"></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个视频"></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 :value="fileLists" :imageStyles="imageStyles" file-mediatype="image">
</uni-file-picker>
<uni-file-picker readonly :value="fileLists" :listStyles="listStyles" file-mediatype="all">
</uni-file-picker>
</view>
</uni-section>
</view>
</template>
<script>
export default {
data() {
return {
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://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b7c7f970-517d-11eb-97b7-0dc4655d6e68.jpg',
extname: 'png',
name: 'shuijiao.png'
}, {
url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b7c7f970-517d-11eb-97b7-0dc4655d6e68.jpg',
extname: 'png',
name: 'uniapp-logo.png'
}, {
url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b7c7f970-517d-11eb-97b7-0dc4655d6e68.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>