代码示例:

    1. <template>
    2. <view>
    3. <u-upload @afterRead="afterReadPic" :fileList="fileList1" :previewFullImage="true" name="1" multiple :maxCount="10"></u-upload>
    4. <button @click="upload">上传</button>
    5. </view>
    6. </template>
    7. <script>
    8. export default {
    9. data() {
    10. return {
    11. fileList1:[]
    12. }
    13. },
    14. methods: {
    15. afterReadPic(e) {
    16. e.file.forEach(file => {
    17. this.fileList1.push({
    18. ...file,
    19. status: 'success',
    20. message: ''
    21. })
    22. })
    23. },
    24. upload() {
    25. console.log(this.fileList1)
    26. uni.uploadFile({
    27. url: 'https://cdp.gsafety.com:61001/gev/api/v1/api/sa/minio/file/upload?module=hazard',
    28. filePath: this.fileList1[0].url,
    29. name: 'file',
    30. header: {
    31. Authorization: 'Bearer 52f13488-2beb-4b8a-8338-a6631c6a7159',
    32. token: '52f13488-2beb-4b8a-8338-a6631c6a7159'
    33. },
    34. success(res) {
    35. console.log(res)
    36. }
    37. })
    38. }
    39. }
    40. }
    41. </script>
    42. <style>
    43. </style>