import { basUrl } from './config' //request.js 此demo为简易封装,开发者可根据自己的业务场景进行修改 export const httpRequest = (url: string, method: any = 'GET', data: any = {}, header: any = {}) => { return new Promise((resolve, reject) => { let newUrl = ''; if (url.includes('https') || url.includes('http')) { newUrl = url; } else { newUrl = `${basUrl}${url}`; } tt.request({ url: newUrl, method: method, data: data, header: header, success: (res) => { resolve(res.data) }, fail: (err) => { reject(err) }, }); }) }