接口域名拆分文件

This commit is contained in:
2023-08-29 17:42:01 +08:00
parent 3e09b4ba47
commit 14b6100257
3 changed files with 137 additions and 133 deletions

View File

@@ -1,14 +1,15 @@
import config from "@/common/config";
//1、首先创建一个工具包utils
//2、创建一个api.js文件
//3、编写api.js内容
//创建一个常量 conset BASE_URL作为默认url地址
const BEST_URL = "https://tcapidemo.tripodeck.com";
export const myRequest = (option) => {
//将封装好的函数导入出去
return new Promise((resolve, reject) => {
uni.request({
url: BEST_URL + option.url, //传入url地址
url: config.baseUrl + option.url, //传入url地址
data: option.data || {}, //请求数据
method: option.method || "GET", //请求方法
header: option.header || {