存入数据要user
<template> <div> <el-container> <el-container> <el-main> <div style="display: flex"> <el-card style="width: 70%"> <div> <el-table :data="users"> <el-table-column label="文件上传"> <template v-slot="scope"> <el-upload class="upload-demo" action="http://localhost:9090/file/upload" :show-file-list="false" :on-success="(row,res,file,fileList) => handleTableFileUpload(scope.row,res,file,fileList)" > <el-button type="primary" size="small" >单温点击上传</el-button > <template #tip> <div class="el-upload__tip" style="font-size: 12px"> 文件最大上传1000M </div> </template> </el-upload> </template> </el-table-column> <el-table-column label="文件上传"> <template v-slot="scope"> <el-image v-if="scope.row.avatar" :src="scope.row.avatar" style="width: 50px;height: 50px;"></el-image> <div><el-button @click="preview(scope.row.avatar)">预览</el-button></div> </template> </el-table-column> </el-table> </div> </el-card> </div> <template #header> <div> <el-upload class="upload-demo" action="http://localhost:9090/file/upload" :show-file-list="false" :on-success="(row,res,file,fileList) => handleTableFileUpload(scope.row,res,file,fileList)" > </el-upload> </div> </template> </el-main> </el-container> </el-container> </div> </template> <script setup> </script> <script> import axios from "axios"; // import request from '@/untils/request'; export default { data() { return { flag: true, users: [] }; }, methods: { handleTableFileUpload(row,file,fileList){ console.log(row,file,fileList) row.avatar = file.response.data; // this.$set(row,'avatar',file.response.data) console.log(row) axios.put('/user/update',row).then(res => { if (res.data.code === '200'){ this.$message.success('上传成功') } else { this.$message.error(res.data.msg) } }) }, handleMultipleFileUpload(response,file,fileList){ console.log(response,file,fileList) this.urls = fileList.map(v => v.response?.data) }, handleFileUpload(response,file,fileList){ this.fileList = fileList } }, mounted() { axios.get("http://localhost:9090/user/selectAll").then((res) => { this.users = res.data.data; }); axios.get("http://localhost:9090/user/selectById/5").then((res) => { console.log(res.data); }); }, }; </script>