axios请求url地址问题

图片描述

图中箭头所指,我在请求的时候这样写url不能请求到这个url,但是打印的时候是能够打印出来的。所以是只能this.$http.get('/login/cellphone')这样写吗,还是说我的写法有问题

阅读 15.9k
5 个回答

问题找到了,就是我自己写的ip地址忘记加 http://

看你的data,你的url_const.ip + '/login/cellphone',所以你请求的url_const.ip + '/login/cellphone',而不是/login/cellphone

axios.get(this.url, {
    params: {
      
    }
  })
  .then(function (response) {
     
       })

不应该是这样子的吗

感觉你应该是配置了全局的 axios 默认值axios.defaults.baseURL

是不是this指向的问题,改成下面的试下

let that=this;
this.$http.get(that.url, {

params: {
  phone:that.phone,
   password:that.password
}

})
.then(function (response) {

 
   })
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题