请求地址
http://www.xxx.cn/api/queryMsg.php
main.js
import axios from 'axios'
Vue.prototype.axios = axios;
axios.defaults.baseURL = '/api'
vue.config.js
module.exports = {
devServer: {
host: 'localhost',
port: 8080,
proxy: {
'/api': {
target:'http://www.xxx.cn/api', //
changeOrigin: true,
pathRewrite:{
'^/api': ''
}
}
}
}
}
work.vue
this.axios.get("/queryMsg.php")
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})