头图

1、在main.js里面,Vue.prototype.$axios = axios之后加入下面两段代码
axios.defaults.baseURL = '/api';

axios.defaults.headers.post['Content-Type'] = 'application/json';

image.png

2、在index.js中proxyTable里面增加
target里面增加要跨域的url

'/api':{

    target: "http://local.laravel8.cn",

    changeOrigin:true,

    pathRewrite:{

        '^/api':''

    }

image.png

3、在实际使用的时候,直接写上要请求的url即可:
image.png


凡二先生
1 声望2 粉丝

谷隐.凡二