vue框架config index.js

配置文件config/index.js下

module.exports={
    dev:{
        proxyTable:{}
    }
}

更改为:

proxyTable:{
    "/api":{
        target:"http://218.78.187.216/api/v1",//调用的接口域名和端口
        changeOrigin:true,
        pathRewrite:{
            "/api":""////用'/api' 代替 'http://218.78.187.216/api/v1'
        }
    }
}

例如:请求地址为:"http://218.78.187.216/api/v1/authentication"
请求的时候可以写为:

 this.$axios.post("/api/anthentication",params).then(res=>{
    console.log(res);
 },err=>{
    console.log(err);
 })

 

posted @ 2022-03-22 10:26  钱小柒  阅读(104)  评论(0编辑  收藏  举报