代码人»首页 技术广场 Vue 查看内容

TypeError: Cannot read properties of undefined (reading 'data') at Object.po

317

主题

3

回帖

1332

积分

管理员

积分
1332
1.页面加载,接口POST请求,报错:



错误1:请求返回空响应   ...index.ts:34  【src/config/axios/index.ts】



错误2:POST请求失败: TypeError: Cannot read properties of undefined (reading 'data')    at Object.post




  1. post: async <T = any>(option: any) => {
  2.     //const res = await request({ method: 'POST', ...option })
  3.     //return res.data as unknown as T
  4.       try {
  5.           const res = await request({ method: 'POST', ...option });
  6.           // 添加空值检查
  7.           if (!res) {
  8.               console.error('<font color="#ff0000">请求返回空响应</font>'); //<font color="#ff0000">错误1</font>
  9.           }
  10.           return res.data as unknown as T;
  11.       } catch (error) {
  12.           console.error('POST请求失败:', error);//<font color="#ff0000">错误2</font>
  13.       }
  14.   },
复制代码











错误1:Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'list') at getList  



上面的错误出处:


const getList = async () => {
  loading.value = true
  try {
    // 工作台获取工作任务分页
    const res = await workbenchApi.getWorkbenchList(queryParams.value)
    list.value = res.list //错误1
    total.value = res.total
    // 获取工作任务统计
    workbenchList.value = await workbenchApi.getWorkbenchCount()
      if(workbenchList.value){
          getDictObj('FLOW_BUS_OPT')
      }
      loading.value = false
  } finally {
    loading.value = false
  }
}


3.上面的接口报错后,页面返回登录页面,进行登录,报错


Uncaught (in promise) Error: No match for
{"name":"Home","params":{}}



登录页面没有跳转,报错提示上面的错误。


怎么解决?





微信扫一扫,分享更方便

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

上一篇: vue3+ts项目开发笔记

下一篇: 没有了

举报 回复

317

主题

3

回帖

1332

积分

管理员

积分
1332
解决办法:



有待测试,看看效果。
付费看帖
剩余 92% 内容需要支付 30.00 元 后可完整阅读
支持付费阅读,激励作者创作更好的作品。会员可8折购买!

举报 回复