vue-simple-uploader多文件上传要怎么写代码
时间: 2023-04-02 19:00:54 浏览: 155
你可以参考以下代码实现vue-simple-uploader多文件上传:
<template>
<div>
<vue-simple-uploader
ref="uploader"
:upload-url="uploadUrl"
:headers="headers"
:multiple="true"
:max-file-size-in-mb="maxFileSizeInMb"
:allowed-file-types="allowedFileTypes"
@upload-success="onUploadSuccess"
@upload-error="onUploadError"
>
<button>选择文件</button>
</vue-simple-uploader>
</div>
</template>
<script>
import VueSimpleUploader from 'vue-simple-uploader';
export default {
components: {
VueSimpleUploader,
},
data() {
return {
uploadUrl: 'your-upload-url',
headers: {
'Authorization': 'Bearer your-token',
},
maxFileSizeInMb: 10,
allowedFileTypes: ['image/jpeg', 'image/png', 'image/gif'],
};
},
methods: {
onUploadSuccess(response, file, fileList) {
console.log('Upload success:', response, file, fileList);
},
onUploadError(error, file, fileList) {
console.log('Upload error:', error, file, fileList);
},
},
};
</script>
阅读全文