vue-api-manager
v1.0.0-alpha
Published
An api manager bases on Vue
Downloads
5
Readme
vue-api-manager
An api manager bases on Vue and Element-UI
Usage
Install
npm install vue-api-manager -S
import api from './api'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import ApiCreator from '../dist'
Vue.use(ElementUI)
Vue.use(ApiCreator, {
modules: api,
beforeRequest (options) {
console.log(options)
},
axios: {
baseURL: '/base-url'
},
mock: 'mock address'
})
Use
export default {
created () {
this.$api('app/list').then(res => {
// ....
}).catch(err => {
// ....
})
}
}
Api directory
├── api
│ │── app
│ │ ├── index.js
│ └── index.js
app/index.js
export default {
BASE_URL: '/sys/app',
api: [
{
name: 'list',
desc: 'get app list',
method: 'GET',
path: 'list',
mock: false
}
]
}
api/index.js
import app from './app'
export default {
app
}