1、在config->index.js
proxyTable: {//设置proxy代理 '/api': { target: 'https://cxxx.cn', changeOrigin: true, pathRewrite: { '^/api': '' //请求时当匹配到url以api开头时会自动把api替换成target所设置的url,但是浏览器本地控制台不会改变 } } }
注:在所有的请求接口前面加/api/
2、后端 + 前端设置
后端开发设置allow-control-Cross-origin: *||指定域名
前端main.js内设置:axios.defaults.withCredentials = false
3、vue-jsonp
npm install vue-jsonp //可以配合vue-resource使用,axios不能