vue2.0跨域的分享
文章目录
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即可:
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论