Skip to content

Commit c1065bb

Browse files
committed
feat: new version
1 parent 0024bcc commit c1065bb

File tree

4 files changed

+76
-71
lines changed

4 files changed

+76
-71
lines changed

dist/vue-axios.es5.js

Lines changed: 73 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,105 @@
11
'use strict';
22

3-
Object.defineProperty(exports, "__esModule", {
4-
value: true
5-
});
6-
73
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
84

9-
/**
10-
* Copied from vue-resource
11-
*/
5+
(function () {
126

13-
var slice = [].slice;
7+
/**
8+
* Copied from vue-resource
9+
*/
1410

11+
var slice = [].slice;
1512

16-
function isFunction(val) {
17-
return typeof val === 'function';
18-
}
1913

20-
var isArray = Array.isArray;
14+
function isFunction(val) {
15+
return typeof val === 'function';
16+
}
2117

22-
function isPlainObject(obj) {
23-
return isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype;
24-
}
18+
var isArray = Array.isArray;
2519

26-
function isObject(obj) {
27-
return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
28-
}
20+
function isPlainObject(obj) {
21+
return isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype;
22+
}
2923

30-
function _merge(target, source, deep) {
31-
for (var key in source) {
32-
if (deep && (isPlainObject(source[key]) || isArray(source[key]))) {
33-
if (isPlainObject(source[key]) && !isPlainObject(target[key])) {
34-
target[key] = {};
35-
}
36-
if (isArray(source[key]) && !isArray(target[key])) {
37-
target[key] = [];
24+
function isObject(obj) {
25+
return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
26+
}
27+
28+
function _merge(target, source, deep) {
29+
for (var key in source) {
30+
if (deep && (isPlainObject(source[key]) || isArray(source[key]))) {
31+
if (isPlainObject(source[key]) && !isPlainObject(target[key])) {
32+
target[key] = {};
33+
}
34+
if (isArray(source[key]) && !isArray(target[key])) {
35+
target[key] = [];
36+
}
37+
_merge(target[key], source[key], deep);
38+
} else if (source[key] !== undefined) {
39+
target[key] = source[key];
3840
}
39-
_merge(target[key], source[key], deep);
40-
} else if (source[key] !== undefined) {
41-
target[key] = source[key];
4241
}
4342
}
44-
}
45-
46-
function merge(target) {
47-
48-
var args = slice.call(arguments, 1);
49-
50-
args.forEach(function (source) {
51-
_merge(target, source, true);
52-
});
5343

54-
return target;
55-
}
44+
function merge(target) {
5645

57-
function options(fn, obj, opts) {
46+
var args = slice.call(arguments, 1);
5847

59-
opts = opts || {};
48+
args.forEach(function (source) {
49+
_merge(target, source, true);
50+
});
6051

61-
if (isFunction(opts)) {
62-
opts = opts.call(obj);
52+
return target;
6353
}
6454

65-
return merge(fn.bind({ $vm: obj, $options: opts }), fn, { $options: opts });
66-
}
55+
function options(fn, obj, opts) {
6756

68-
/**
69-
* Install plugin
70-
* @param Vue
71-
*/
57+
opts = opts || {};
7258

73-
function plugin(Vue, axios) {
59+
if (isFunction(opts)) {
60+
opts = opts.call(obj);
61+
}
7462

75-
if (plugin.installed) {
76-
return;
63+
return merge(fn.bind({ $vm: obj, $options: opts }), fn, { $options: opts });
7764
}
7865

79-
if (!axios) {
80-
console.error('You have to install axios');
81-
return;
82-
}
66+
/**
67+
* Install plugin
68+
* @param Vue
69+
* @param axios
70+
*/
8371

84-
Vue.axios = axios;
72+
function plugin(Vue, axios) {
8573

86-
Object.defineProperties(Vue.prototype, {
74+
if (plugin.installed) {
75+
return;
76+
}
8777

88-
axios: {
89-
get: function get() {
90-
return options(Vue.axios, this, this.$options.axios);
91-
}
78+
if (!axios) {
79+
console.error('You have to install axios');
80+
return;
9281
}
9382

94-
});
95-
}
83+
Vue.axios = axios;
9684

97-
if (typeof window !== 'undefined' && window.Vue) {
98-
window.Vue.use(plugin);
99-
}
85+
Object.defineProperties(Vue.prototype, {
10086

101-
exports.default = plugin;
87+
axios: {
88+
get: function get() {
89+
return options(Vue.axios, this, this.$options.axios);
90+
}
91+
}
92+
93+
});
94+
}
95+
96+
if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) == "object") {
97+
module.exports = plugin;
98+
} else if (typeof define == "function" && define.amd) {
99+
define([], function () {
100+
return plugin;
101+
});
102+
} else if (window.Vue && window.axios) {
103+
Vue.use(plugin, window.axios);
104+
}
105+
})();

dist/vue-axios.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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.0",
3+
"version": "1.2.1",
44
"description": "A small wrapper for integrating axios to Vuejs",
55
"main": "dist/vue-axios.min.js",
66
"scripts": {

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ function options(fn, obj, opts) {
6161
/**
6262
* Install plugin
6363
* @param Vue
64+
* @param axios
6465
*/
6566

6667
function plugin(Vue, axios) {

0 commit comments

Comments
 (0)