You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
2.8 KiB
111 lines
2.8 KiB
1 year ago
|
<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>
|