当前位置: 首页 > Web前端 > vue.js

Vue2.0跨域分享

时间:2023-03-31 14:47:44 vue.js

1。在main.js中,在Vue.prototype.$axios=axiosaxios.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即可: