-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (45 loc) · 1.12 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var Vue = null;
var applyMixin = function(Vue) {
var version = Number(Vue.version.split(".")[0]);
if (version >= 2) {
Vue.mixin({
beforeCreate: hoodieInit
});
} else {
var _init = Vue.prototype._init;
Vue.prototype._init = function(options) {
if (options === void 0) options = {};
options.init = options.init
? [hoodieInit].concat(options.init)
: hoodieInit;
_init.call(this, options);
};
}
function hoodieInit() {
var options = this.$options;
if (options.hoodie) {
this.$hoodie =
typeof options.hoodie === "function"
? options.hoodie()
: options.hoodie;
} else if (options.parent && options.parent.$hoodie) {
this.$hoodie = options.parent.$hoodie;
}
}
};
function install(_Vue, options) {
if (Vue && _Vue === Vue) {
if (process.env.NODE_ENV !== "production") {
console.error(
"[hoodie] already installed. Vue.use(VueHoodie) should be called only once."
);
}
return;
}
Vue = _Vue;
applyMixin(_Vue, options);
}
var VueHoodie = {
install: install
};
export default VueHoodie;