<template> <el-upload ref="upload" :auto-upload="false" accept="" :show-file-list='false' :on-change="handleChangeUpload" action="#" class="upload-demo" multiple> <el-button type="primary">Click to uploadel-button> el-upload>template><script setup>import { onMounted, onUnmounted, reactive, toRefs, watch, onActivated } from 'vue'// import { fileUpload } from '@/api/grid/common'function handleChangeUpload(file) { let formData = new FormData() formData.append('文件', file.raw) fileUpload(formData).then(res => {//fileUpload换成你自己接口 if (res.code == '200') { ElMessage({ type: 'success', message: '上传成功', }) } else { ElMessage.error(res.message) } // console.log(res); }).finally()}script>
来源地址:https://blog.csdn.net/guo__hang/article/details/132556343