裂变星小程序-25.03.04
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.

59 lines
1.0 KiB

  1. <template>
  2. <view>
  3. <uv-upload
  4. :accept="accept"
  5. :maxCount="1"
  6. :width="width"
  7. :height="height"
  8. :previewImage="false"
  9. :compressed="false"
  10. :sizeType="['original']"
  11. @afterRead="afterRead"
  12. @delete="deleteFile"
  13. >
  14. <slot :value="value"></slot>
  15. </uv-upload>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. props: {
  21. value: {
  22. default: null
  23. },
  24. accept: {
  25. type: String,
  26. default: 'image' // all | media | image | file | video
  27. },
  28. width: {
  29. type: Number | String,
  30. default: null,
  31. },
  32. height: {
  33. type: Number | String,
  34. default: null,
  35. },
  36. },
  37. data() {
  38. return {
  39. fileList: [],
  40. }
  41. },
  42. methods: {
  43. deleteFile(){
  44. this.fileList = []
  45. this.$emit('input', null)
  46. },
  47. afterRead(e){
  48. this.$Oss.ossUpload(e.file.url).then(url => {
  49. this.fileList = [url]
  50. this.$emit('input', url)
  51. })
  52. },
  53. },
  54. }
  55. </script>
  56. <style scoped lang="scss">
  57. </style>