Taro+Vue3+TypeScript实现手机相册图片上传功能
<template>
<view>
<nut-uploader
:url="uploadUrl"
:delete-icon="iconDelete"
:before-xhr-upload="beforeXhrUpload"
@delete="handleDelete">
</nut-uploader>
</view>
</template>
<script setup lang='ts'>
const iconDelete = require('@/assets/icons/delete_icon.png')
const uploadUrl = 'https://xxxx/file/uploadImgs';
const beforeXhrUpload = (taroUploadFile: any, options: any) => {
const uploadTask = taroUploadFile({
url: options.url,
filePath: options.taroFilePath,
fileType: options.fileType,
header: {
'Content-Type': 'multipart/form-data',
...options.headers,
},
// 在这个地方声明接口传参内容
formData: {
// 是否压缩(定义实际接口需