12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- /*
- * @Description: axois配置文件
- * @Author: Napier
- * @LastEditors: Napier
- * @LastEditorTime: 2021-06-17
- */
- export default {
- install (Vue) {
- // 请求前缀
- // test
- // Vue.prototype.$axios.defaults.baseURL = 'http://127.0.0.1:300'
- // http
- // Vue.prototype.$axios.defaults.baseURL = 'http://139.155.20.56:300'
- // https
- // Vue.prototype.$axios.defaults.baseURL = 'http://139.155.20.56:300'
- Vue.prototype.$axios.defaults.baseURL = 'https://server.itopmap.com'
-
- // 设置超时时间
- 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)
- })
- }
- }
- }
|