为了账号安全,请及时绑定邮箱和手机立即绑定

vue在开发模式下,怎么改变向后台发送请求的默认地址

vue在开发模式下,怎么改变向后台发送请求的默认地址

弑天下 2019-05-24 10:27:22
向后台发送请求现在的写法this.$http.get('http://1.1.1.1:8080/product/getAllProducts?page=0').then((response)=>{me.tableData=response.body.data.content}).catch(function(response){/***todo:此处待补充错误处理**/})我希望改成下面写法但是效果还是http://1.1.1.1:8080/product/getAllProducts?page=0this.$http.get('product/getAllProducts?page=0').then((response)=>{me.tableData=response.body.data.content}).catch(function(response){/***todo:此处待补充错误处理**/})为此,我改了config/index.js文件中的dev:{proxyTable:{'/api':{target:'http://1.1.1.1:8080',changeOrigin:true}}但是并不能实现我想要的效果,求助求助注意:我用的是vue-resource,怎么写呢?而且我就是开发模式下请求需要指定地址,在build模式下正常使用localhost
查看完整描述

2 回答

?
沧海一幻觉

TA贡献1824条经验 获得超5个赞

this.$http.get('product/getAllProducts?page=0')
请求前面少了一个'/',改成
this.$http.get('/product/getAllProducts?page=0'),
其实可以控制台调试一下,看看接口请求的详细信息,一步一步找原因可以找到的。
                            
查看完整回答
反对 回复 2019-05-24
  • 2 回答
  • 0 关注
  • 2859 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号