vue ajax问题

export default {

data(){
    return{
        url:'www.aa.com',
    }
},
mounted(){
    this.getC();
},
methods:{
    getC:function(){
        $.ajax({
            url:this.url+'/api/',
            type:'get',
            dataType:"json",
            success(res){
                console.log(res)
            }
        })
    }
}

}

假设这样请求,为什么url会加上本地URL呢??
怎么解决??
GET http://localhost:8080/www.aa.com/api/ 404 (Not Found)

其他页面都没有请求,只有这一个页面发生请求。

阅读 2k
1 个回答

因为用了相对路径,
解决方式是按照aa.com使用协议,加上http://https:////

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