UNPKG

691 BJavaScriptView Raw
1(function () {
2
3/**
4 * Install plugin
5 * @param Vue
6 * @param axios
7 */
8
9function plugin(Vue, axios) {
10
11 if (plugin.installed) {
12 return
13 }
14 plugin.installed = true
15
16 if (!axios) {
17 console.error('You have to install axios')
18 return
19 }
20
21 Vue.axios = axios
22
23 Object.defineProperties(Vue.prototype, {
24
25 axios: {
26 get() {
27 return axios
28 }
29 },
30
31 $http: {
32 get() {
33 return axios
34 }
35 }
36
37 })
38}
39
40if (typeof exports == "object") {
41 module.exports = plugin
42} else if (typeof define == "function" && define.amd) {
43 define([], function(){ return plugin })
44} else if (window.Vue && window.axios) {
45 Vue.use(plugin, window.axios)
46}
47
48})();