问题描述
所以我用这样的代理调用api:
xx.vue:
getVersion(){
axios.get('/service/details/')
.then(response => this.version = response.data.build.version)
vue.config.js :
module.exports = {
devServer: {
proxy: {
'^/service/': {
target: 'http://localhost:8181/',changeOrigin: true,secure:false,pathRewrite: {'^/service': '/service/'},logLevel: 'debug'
}
}
}
}
html:
<p v-bind="getVersion()"> Version : {{version}} </p>
并且我想使用相同的方法获取另一个服务的版本。该服务具有不同的端口和相同的路径(/service/details),我无法直接在 config.vue.js 中添加:
'^/service/': {
target: 'http://localhost:5051/',logLevel: 'debug'
}
PS:我无法更改后端的网址
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)