当前位置: 首页 > news >正文

2.Vue报错Cannot read properties of undefined (reading ‘then‘)

1.出现报错

Cannot read properties of undefined (reading ‘then’),
代码为

 uploadFile(e.target.files[0]).then((res) => {alert(JSON.stringify(res));});

2.原因

是因为uploadFile方法没有返回值,于是我又检查了一遍代码,发现我的retrun 写错位置了

// 公共方法-上传文件
export function uploadFile(file) {// 用form表单方式提交const formData = new FormData();return  formData.append('file', file);request({url: '/common/upload',method: 'post',data: formData});
}

我写在了 调用Api接口之前,问题找到。

http://www.lryc.cn/news/140153.html

相关文章:

  • 【LeetCode 】数组简介
  • 一文解析block io生命历程
  • Python爬虫学习之旅:从入门到精通,要学多久?
  • HarmonyOS/OpenHarmony(Stage模型)卡片开发应用上下文Context使用场景一
  • MAE 论文精读 | 在CV领域自监督的Bert思想
  • C++中内存的分配
  • Qt中的垂直布局QVBoxLayout和水平布局QHBoxLayout
  • 【C#学习笔记】委托和事件
  • 堆排序简介
  • React Diff算法
  • 07 mysql5.6.x docker 启动, 无 config 目录导致客户端连接认证需要 10s
  • GO GC
  • ECharts配合Node.js爬虫实现数据可视化
  • [Linux] C获取键盘,鼠标数据
  • 户外跑步用什么耳机、户外运动耳机推荐
  • ubuntu设置系统代理
  • java定时任务如何取消
  • gitlab 9.05 版本获取合并请求的API接口报错404是为什么
  • 微服务(多级缓存)
  • 阿里云配置MySQL-server 8.0远程登录
  • 清洁能源使用的社会发展意义
  • 针对论坛系统进行功能测试和性能测试
  • Android App的设计规范
  • paddleclas ImportError: cannot import name ‘Identity‘ from ‘paddle.nn‘
  • Debezium系列之:深入理解Debezium Server Operator和实际应用Debezium Server Operator案例详解
  • ansible批量创建crontab文件并添加到定时任务
  • 什么是 API ?
  • CSS实现内凹圆角,从而实现圆角边框
  • Spring中的自定义注解
  • 前端需要理解的设计模式知识