我正在使用vue cli3进行设置.我已经在vue.config.js
文件中设置了devServer api:
devServer: {
proxy: {
'/api': {
target: 'http://localhost:1888/apps/test/mainapp.php/',
changeOrigin: true,
},
},
}
我还需要将路径"https://server/myapp/main.php/"设置为生产API路径,但我似乎在documentation中找不到任何关于如何操作的信息.感谢您的帮助.
我在代码中所做的简单示例:
methods: {
login() {
this.axios.post('/api/test')
.then((resp) => {
console.log(resp);
})
.catch(() => {
console.log('err:' , err);
});
},
},