commit | author | age
|
9bcb19
|
1 |
const VueAxios = { |
I |
2 |
vm: {}, |
|
3 |
// eslint-disable-next-line no-unused-vars |
|
4 |
install (Vue, instance) { |
|
5 |
if (this.installed) { |
|
6 |
return |
|
7 |
} |
|
8 |
this.installed = true |
|
9 |
|
|
10 |
if (!instance) { |
|
11 |
// eslint-disable-next-line no-console |
|
12 |
console.error('You have to install axios') |
|
13 |
return |
|
14 |
} |
|
15 |
|
|
16 |
Vue.axios = instance |
|
17 |
|
|
18 |
Object.defineProperties(Vue.prototype, { |
|
19 |
axios: { |
|
20 |
get: function get () { |
|
21 |
return instance |
|
22 |
} |
|
23 |
}, |
|
24 |
$http: { |
|
25 |
get: function get () { |
|
26 |
return instance |
|
27 |
} |
|
28 |
} |
|
29 |
}) |
|
30 |
} |
|
31 |
} |
|
32 |
|
|
33 |
export { |
|
34 |
VueAxios |
|
35 |
} |