0
点赞
收藏
分享

微信扫一扫

Vue 实现请求转发【Vue小技巧】

通过nodejs的请求转发到后台,

前端地址:http://localhost:8080   后端地址:http://localhost:8081

 

在vue.config.js里面配置这个代理(找到config/index.js 配置文件 )

module.exports = {
derServer:{
proxy:{
'/api':{
target:'http://localhost:3000'
}
}
}

}

 然后就可以axios.get('/api').then(res=> {})


举报

相关推荐

0 条评论