1、在main.js里面,Vue.prototype.$axios = axios之后加入下面两段代码
axios.defaults.baseURL = '/api';
axios.defaults.headers.post['Content-Type'] = 'application/json';
2、在index.js中proxyTable里面增加
target里面增加要跨域的url
'/api':{
target: "http://local.laravel8.cn",
changeOrigin:true,
pathRewrite:{
'^/api':''
}
3、在实际使用的时候,直接写上要请求的url即可:
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。