先给最外层包一个service,也就是每个接口外层都有一个/service了 export const http = axios.create({ baseURL: '/service', withCredentials: false, //headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, }); export const http1 = axios.create({ baseURL: '/service', withCredentials: false }); export const httpLayer = axios.create({ baseURL: '/service', withCredentials: false }); 然后代理的时候遇到下面的情况:之前是/publicService'单独写一次代理,现在由于都包了一层proxyTable: { '/service': { target: 'http://222.85.148.140:5000', changeOrigin: true, pathRewrite: function (path, req) { return path.replace('/service', ''); } }, '/publicService': { target: 'http://222.85.148.140:5000', changeOrigin: true, pathRewrite: function (path, req) { return path.replace('/service', ''); } },},/service,所以就代理一次就好了
axios中的http中的baseURL怎么用?
最新推荐文章于 2025-03-24 10:16:13 发布