1
1
( function ( ) {
2
2
3
- /**
4
- * Copied from vue-resource
5
- */
6
-
7
- const { slice } = [ ] ;
8
-
9
- function isFunction ( val ) {
10
- return typeof val === 'function' ;
11
- }
12
-
13
- const isArray = Array . isArray ;
14
-
15
- function isPlainObject ( obj ) {
16
- return isObject ( obj ) && Object . getPrototypeOf ( obj ) == Object . prototype ;
17
- }
18
-
19
- function isObject ( obj ) {
20
- return obj !== null && typeof obj === 'object' ;
21
- }
22
-
23
- function _merge ( target , source , deep ) {
24
- for ( var key in source ) {
25
- if ( deep && ( isPlainObject ( source [ key ] ) || isArray ( source [ key ] ) ) ) {
26
- if ( isPlainObject ( source [ key ] ) && ! isPlainObject ( target [ key ] ) ) {
27
- target [ key ] = { } ;
28
- }
29
- if ( isArray ( source [ key ] ) && ! isArray ( target [ key ] ) ) {
30
- target [ key ] = [ ] ;
31
- }
32
- _merge ( target [ key ] , source [ key ] , deep ) ;
33
- } else if ( source [ key ] !== undefined ) {
34
- target [ key ] = source [ key ] ;
35
- }
36
- }
37
- }
38
-
39
- function merge ( target ) {
40
-
41
- var args = slice . call ( arguments , 1 ) ;
42
-
43
- args . forEach ( ( source ) => {
44
- _merge ( target , source , true ) ;
45
- } ) ;
46
-
47
- return target ;
48
- }
49
-
50
- function options ( fn , obj , opts ) {
51
-
52
- opts = opts || { } ;
53
-
54
- if ( isFunction ( opts ) ) {
55
- opts = opts . call ( obj ) ;
56
- }
57
-
58
- return merge ( fn . bind ( { $vm : obj , $options : opts } ) , fn , { $options : opts } ) ;
59
- }
60
-
61
3
/**
62
4
* Install plugin
63
5
* @param Vue
@@ -81,10 +23,16 @@ function plugin(Vue, axios) {
81
23
82
24
axios : {
83
25
get ( ) {
84
- return options ( Vue . axios , this , this . $options . axios ) ;
26
+ return axios ;
85
27
}
86
28
} ,
87
29
30
+ $http : {
31
+ get ( ) {
32
+ return axios ;
33
+ }
34
+ }
35
+
88
36
} ) ;
89
37
}
90
38
0 commit comments