Skip to content

Commit f57510a

Browse files
committed
feat: restructure
1 parent 333e788 commit f57510a

File tree

2 files changed

+8
-60
lines changed

2 files changed

+8
-60
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-axios",
3-
"version": "1.2.2",
3+
"version": "2.0.0",
44
"description": "A small wrapper for integrating axios to Vuejs",
55
"main": "dist/vue-axios.min.js",
66
"scripts": {

src/index.js

Lines changed: 7 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,5 @@
11
(function () {
22

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-
613
/**
624
* Install plugin
635
* @param Vue
@@ -81,10 +23,16 @@ function plugin(Vue, axios) {
8123

8224
axios: {
8325
get() {
84-
return options(Vue.axios, this, this.$options.axios);
26+
return axios;
8527
}
8628
},
8729

30+
$http: {
31+
get() {
32+
return axios;
33+
}
34+
}
35+
8836
});
8937
}
9038

0 commit comments

Comments
 (0)