index.vue
<u-upload
ref="upload"
max-count="6"
:header="header"
:action="action"
:custom-btn="true"
:show-tips="false"
:show-progress="false"
@on-success="successUpload"
@on-remove="removeFile"
></u-upload>
接口、请求头部
data() {
fileList: [],
header: {
'Content-Type': 'multipart/form-data',
Authorization: 'Bearer ' + uni.getStorageSync('access_token')
},
}
computed: {
action() {
return url.baseURL + '/upload'
}
},
方法
successUpload(data, index, lists, name) {
this.fileList.push(data.data)
},
removeFile(index, lists, name) {
this.fileList.splice(index, 1)
}