八月未央txt下载,睡美宁,3d太湖钓叟字谜汇总
在不同域之间访问是比较常见,在本地调试访问远程服务器。。。。这就是有域问题。
vue解决通过proxytable:
在 config/index.js 配置文件中
dev: { env: require('./dev.env'), port: 8080, autoopenbrowser: true, assetssubdirectory: 'static', assetspublicpath: '/', //proxytable: {}, proxytable: proxyconfig.proxylist, // css sourcemaps off by default because relative paths are "buggy" // with this option, according to the css-loader readme // (https://github.com/webpack/css-loader#sourcemaps) // in our experience, they generally work as expected, // just be aware of this issue when enabling this option. csssourcemap: false }
划红线部分就是设置代理参数:
在config目录创建,proxyconfig.js 写入
module.exports = { proxylist: { '/apis': { // 测试环境 target: 'https://goods.footer.com', // 接口域名 changeorigin: true, //是否跨域 pathrewrite: { '^/apis': '' //需要rewrite重写的, } } } }
在 config/index.js 配置文件上边引入
var proxyconfig = require('./proxyconfig')
使用:
服务器提供接口:https://goods.footer.com/health/list
vue请求
var obj = { pagesize: 20 } this.$http.get( '/apis/health/list',{params: obj}) .then(function(res){ // 成功回调 },function(){ alert("error") })
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
VUE+elementui组件在table-cell单元格中绘制微型echarts图
Vue通过getAction的finally来最大程度避免影响主数据呈现问题
vue 路由懒加载中给 Webpack Chunks 命名的方法
网友评论