https://developers.weixin.qq.com/miniprogram/dev/apietworkequest/wx.request.html
每个请求的业务代码都要带上token,如果有个全局拦截器就好了,不用每个请求的代码添加相同的参数。(业务发起请求后,全局拦截器统一在请求头上加上tooken)
增加一个请求的全局拦截器(可参考vue框架的全局拦截器)Add a request global interceptor (refer to the global interceptor of the vue framework)
增加一个请求的全局拦截器(可参考vue框架的全局拦截器)框架类型 | 问题类型 | API/组件名称 | 终端类型 | 微信版本 | 基础库版本 |
---|---|---|---|---|---|
小程序 | Bug | 发起后端请求(不限于wx.request) | 微信iOS客户端 | 暂无 | 暂无 |
https://developers.weixin.qq.com/miniprogram/dev/apietworkequest/wx.request.html
每个请求的业务代码都要带上token,如果有个全局拦截器就好了,不用每个请求的代码添加相同的参数。(业务发起请求后,全局拦截器统一在请求头上加上tooken)
Framework type problem type API / component name terminal type wechat version basic library version applet bug initiates back end request (not limited to) wx.request )No wechat IOS client https://developers.weixin.qq.com/miniprogram/dev/apietworkequest/wx.request.html The business code of each request should be accompanied by a token. If there is a global interceptor, it is good. It is not necessary to add the same parameters to the code of each request. (after a business request is initiated, the global interceptor adds a token to the request header.) in the code fragment, the business code of each request should be accompanied with a token. If there is a global interceptor, it is good. It is not necessary to add the same parameters to the code of each request. (after a service initiates a request, the global interceptor adds a token to the request header)
回答:
是啊 自己封装request方法 做什么都行
这么简单的 自己封装呀,官方给你转头,房子自己造
你使用的微信原生的还是vue框架呢?