//config index.js
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/v1': {
target: 'http://172.16.5.168:8090',
changeOrigin: true
},
'/api': {
target: 'http://172.16.5.168:8000',
changeOrigin: true,
}
},
// Various Dev Server settings
host: '0.0.0.0', // 原本是localhost 在同一局域网下的电脑无法访问本电脑打开的页面
//api.js
export default {
install: () => {
let http = Vue.axios
const api = {
login: resource('v1/users/login', http, { //第一个地址请求的方式
post: params => http.post('v1/users/login', params)
}),
client: resource('api/users/login', http, { //第二个地址请求的方式
post: params => http.post('api/users/login', params)
}),
}
Vue.api = api;
Vue.prototype.$api = api;
}
}
网友评论