请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

老师我这里用this.$request报错,我应该怎么修改呢?

login.vue:15 Uncaught (in promise) TypeError: this.$request is not a function
at Proxy.mounted (login.vue:15:10)
at callWithErrorHandling (runtime-core.esm-bundler.js:155:22)
at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:164:21)
at Array.hook.__weh.hook.__weh (runtime-core.esm-bundler.js:2667:29)
at flushPostFlushCbs (runtime-core.esm-bundler.js:356:32)
at flushJobs (runtime-core.esm-bundler.js:401:9)

正在回答 回答被采纳积分+3

2回答

河畔一角 2022-02-25 15:05:42

这是Vue3要先挂载到全局对象上,我们课程讲的是通过app.config.globalProperties来挂载的,使用的时候要用proxy.$request,你看下源码和视频

1 回复 有任何疑惑可以回复我~
慕粉3946981 2022-03-01 16:34:54
import {getCurrentInstance} from 'vue'
const globalProperties = getCurrentInstance().appContext.config.globalProperties 
globalProperties.$request


0 回复 有任何疑惑可以回复我~
  • getCurrentInstance方法会解构一个proxy对象
    回复 有任何疑惑可以回复我~ 2022-03-01 23:06:58
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号