Vue warn TypeError: Cannot read properties of undefined (reading ‘post‘)

在点击立即捐赠按钮之后就会有这两个提示,前后端都检查了一遍,还是不知道哪里有问题,麻烦大家帮我看看,谢谢

img


                  "8">
                    "物资图片" prop="unit">
                      "image/jpeg,image/png"
                          :on-preview="handlePreview"
                          :on-remove="handleRemove"
                          :before-remove="beforeRemove"
                          ref="upload"
                          action=""
                          :http-request="upload"
                          :auto-upload="false"
                          :before-upload="onBeforeUpload"
                          multiple
                          :limit="1"
                          :on-exceed="handleExceed"
                          v-model="addForm.pictures">
                        "small" type="primary">点击上传
                        
"tip" class="el-upload__tip">只能上传jpg/png文件,且不超过1M
type="primary" @click="addIn">立即捐赠 upload (file) { const _this = this let formdata = new FormData() // 上传图片并返回路径 formdata.append('pictures', file.file) this.$axios.post('/uploadImage', formdata, { headers: { 'Content-Type': 'multipart/form-data' }}).then((resp) => { if (resp.status === 200) { console.log(resp.data) // this.addForm.pictures = resp.data; // 设置图片回显 _this.form.f_logo = resp.data _this.$message({type: 'success', message: '图片上传成功!'}) } }).catch(() => { this.$message({type: 'info', message: '图片太大或格式有误,上传失败,请重新上传!'}) }) } final static String PIC_PATH = "pictures/"; @PostMapping("/api/uploadImage") public String uploadImage(MultipartHttpServletRequest multiRequest, HttpServletRequest request){ System.out.println("上传图片"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); //生成日期格式 String datePrefix = dateFormat.format(new Date()); //生成当前日期作为前缀 String savePath = "src/main/resources/" + PIC_PATH; // 存储路径 File folder = new File(savePath+datePrefix); //生成带当前日期的文件路径 if(!folder.isDirectory()){ folder.mkdirs(); } String randomName = Objects.requireNonNull(multiRequest.getFile("pictures")).getOriginalFilename(); //获取图片名 //生成随机数确保唯一性,并加上图片后缀 assert randomName != null; String saveName = UUID.randomUUID().toString() + randomName.substring(randomName.lastIndexOf("."),randomName.length()); String absolutePath = folder.getAbsolutePath(); //转换成绝对路径 try { File fileToSave = new File(absolutePath + File.separator + saveName); Objects.requireNonNull(multiRequest.getFile("pictures")).transferTo(fileToSave); // 图片存储到服务端 String returnPath = request.getScheme() + "://" + request.getServerName()+":"+request.getServerPort() + "/pictures/" + datePrefix +"/"+ saveName; return returnPath; }catch (Exception e){ e.printStackTrace(); } return null; } @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("Http://localhost:8080","null") .allowedMethods("GET","POST","PUT","OPTIONS","DELETE") .allowCredentials(true) .allowedHeaders("*") .maxAge(3600); } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/pictures/**") .addResourceLocations("file:" + System.getProperty("user.dir")+"\\src\\main\\resources\\pictures\\"); } } ## 静态资源访问路径 spring.mvc.static-path-pattern=/** ## 静态资源映射路径 web.resources.static-locations=classpath:/

你这语法有问题吧,js 可以直接在页面写?