/* * @Description: axois配置文件 * @Author: Napier * @LastEditors: Napier * @LastEditorTime: 2021-06-17 */ export default { install (Vue) { // 请求前缀 // Vue.prototype.$axios.defaults.baseURL = 'http://127.0.0.1:300' // Vue.prototype.$axios.defaults.baseURL = 'http://192.168.124.11:300' // 设置超时时间 Vue.prototype.$axios.defaults.timeout = 10000 // 请求封装 Vue.prototype.request = function (url, method, data, success, header) { this.$axios({ url: url, method: method, headers: header || { 'Accept': 'application/json' }, data: method === 'post' ? JSON.stringify(data) : {}, params: method === 'get' ? data : {} }) .then(res => { if (success) { success(res.data) } }) .catch(res => { console.log(res) }) } } }