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

57 lines
1011 B

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