您的位置:首页 > 汽车 > 时评 > 流动性管理_编程网站scratch_营销工具有哪些_武汉百度开户代理

流动性管理_编程网站scratch_营销工具有哪些_武汉百度开户代理

2024/9/21 3:01:27 来源:https://blog.csdn.net/weixin_40874076/article/details/142347259  浏览:    关键词:流动性管理_编程网站scratch_营销工具有哪些_武汉百度开户代理
流动性管理_编程网站scratch_营销工具有哪些_武汉百度开户代理

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

注意事项

在这里插入图片描述
在这里插入图片描述

uni.request 请求封装

请求和上传文件拦截器

uniapp 拦截器: uni.addInterceptor

接口说明:接口文档

实现需求

  1. 拼接基础地址
  2. 设置超时时间
  3. 添加请求头标识
  4. 添加 token

参考代码

// src/utils/http.ts// 请求基地址
const baseURL = 'https://pcapi-xiaotuxian-front-devtest.itheima.net'// 拦截器配置
const httpInterceptor = {// 拦截前触发invoke(options: UniApp.RequestOptions) {// 1. 非 http 开头需拼接地址if (!options.url.startsWith('http')) {options.url = baseURL + options.url}// 2. 请求超时options.timeout = 10000// 3. 添加小程序端请求头标识options.header = {'source-client': 'miniapp',...options.header,}// 4. 添加 token 请求头标识const memberStore = useMemberStore()const token = memberStore.profile?.tokenif (token) {options.header.Authorization = token}},
}// 拦截 request 请求
uni.addInterceptor('request', httpInterceptor)
// 拦截 uploadFile 文件上传
uni.addInterceptor('uploadFile', httpInterceptor)

常见问题

问: 为什么用手机预览没有数据?

答: 微信小程序端,需登录 微信公众平台 配置以下地址为合法域名 👇
https://pcapi-xiaotuxian-front-devtest.itheima.net

配置步骤
【开发与服务】–【开发管理】–【开发设置】–【服务器域名】

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com