vue-cli脚手架里面的config/index.js里面有一个proxyTable,将
proxyTable: {}
变成
proxyTable: {
'/api': {
target: 'localhost:8088/',
changeOrigin: true,
pathRewrite: {
'^/api': '/api'
}
}
}
然后请求方式变成:
export default {
login () {
this.$http.get('api/getAccount')
.then(res => console.log(res))
.catch(rej => console.log(rej))
}
}
后端:
router.get('/api/getAccount', (req, res) => {
});
网友评论