file-picker.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <view class="container">
  3. <uni-card :is-shadow="false" is-full>
  4. <text class="uni-h6">文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间。</text>
  5. </uni-card>
  6. <uni-section title="只选择图片" type="line">
  7. <view class="example-body">
  8. <uni-file-picker limit="9" title="最多选择9张图片"></uni-file-picker>
  9. </view>
  10. </uni-section>
  11. <uni-section title="只选择视频" type="line">
  12. <view class="example-body">
  13. <uni-file-picker limit="9" file-mediatype="video" title="最多选择9个视频"></uni-file-picker>
  14. </view>
  15. </uni-section>
  16. <!-- #ifdef H5 || MP-WEIXIN || MP-JD -->
  17. <uni-section title="选择任意文件" type="line">
  18. <view class="example-body">
  19. <uni-file-picker limit="5" file-mediatype="all" title="最多选择5个文件"></uni-file-picker>
  20. </view>
  21. </uni-section>
  22. <!-- #endif -->
  23. <uni-section title="自定义图片大小" type="line">
  24. <view class="example-body custom-image-box">
  25. <text class="text">选择头像</text>
  26. <uni-file-picker limit="1" :del-icon="false" disable-preview :imageStyles="imageStyles"
  27. file-mediatype="image">选择</uni-file-picker>
  28. </view>
  29. </uni-section>
  30. <uni-section title="自定义图片大小" type="line">
  31. <view class="example-body ">
  32. <uni-file-picker readonly :value="fileLists" :imageStyles="imageStyles" file-mediatype="image">
  33. </uni-file-picker>
  34. <uni-file-picker readonly :value="fileLists" :listStyles="listStyles" file-mediatype="all">
  35. </uni-file-picker>
  36. </view>
  37. </uni-section>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. imageStyles: {
  45. width: 64,
  46. height: 64,
  47. border: {
  48. radius: '50%'
  49. }
  50. },
  51. listStyles: {
  52. // 是否显示边框
  53. border: true,
  54. // 是否显示分隔线
  55. dividline: true,
  56. // 线条样式
  57. borderStyle: {
  58. width: 1,
  59. color: 'blue',
  60. style: 'dashed',
  61. radius: 2
  62. }
  63. },
  64. fileLists: [{
  65. url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b7c7f970-517d-11eb-97b7-0dc4655d6e68.jpg',
  66. extname: 'png',
  67. name: 'shuijiao.png'
  68. }, {
  69. url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b7c7f970-517d-11eb-97b7-0dc4655d6e68.jpg',
  70. extname: 'png',
  71. name: 'uniapp-logo.png'
  72. }, {
  73. url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b7c7f970-517d-11eb-97b7-0dc4655d6e68.jpg',
  74. extname: 'png',
  75. name: 'shuijiao.png'
  76. }]
  77. }
  78. },
  79. methods: {
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. .example-body {
  85. padding:10px;
  86. padding-top: 0;
  87. }
  88. .custom-image-box {
  89. /* #ifndef APP-NVUE */
  90. display: flex;
  91. /* #endif */
  92. flex-direction: row;
  93. justify-content: space-between;
  94. align-items: center;
  95. }
  96. .text {
  97. font-size: 14px;
  98. color: #333;
  99. }
  100. </style>