1.設置koa2服務器從本地代理轉發
修改:項目/config/index.js-->dev中
proxyTable: {
'/api': {
target: 'http://localhost:3000',
changeOrigin: true,
pathRewrite: { //須要rewrite重寫的, 若是在服務器端作了處理則能夠不要這段
'^/api/': ''
}
}
},vue
//--------------------------------------------------
dev: {
env: require('./dev.env'),
port: 8080,
autoOpenBrowser: true,
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/api': {
target: 'http://localhost:3000',
changeOrigin: true,
pathRewrite: { //須要rewrite重寫的, 若是在服務器端作了處理則能夠不要這段
'^/api/': ''
}
}
},
//--------------------------------------------------ios
2.axios訪問路徑改成:
axGet('/api/hall/getRoomList',{},function(res){
alert(res.data);
},function(err){
alert(err);
});axios
3.必定要重啓vue服務器api