7.3 节 使用 getCurrentInstance 获取 ctx问题

来源:3-11 【资料梳理】接口文档---用户管理

快乐源泉

2021-08-23

老师您好:

const { ctx } = getCurrentInstance()
const { list, page } = await ctx.$api.getUserList()

ctx 获取不到globalProperties定义的 $api

图片描述

 const internalInstance = getCurrentInstance()
 const { list, page } = await internalInstance.appContext.config.globalProperties.$api.getUserList()
写回答

1回答

河畔一角

2021-08-23

ctx换成proxy试一下

1
3
ude
回复
快乐源泉
3q!
2023-04-27
共3条回复

Vue3+ElementPlus+Koa2 全栈开发后台系统

从前端晋级到全栈,让你的未来发展有更多可能

1069 学习 · 580 问题

查看课程