提交 | 用户 | 时间
|
0ca254
|
1 |
import Dict from './Dict' |
A |
2 |
import { mergeOptions } from './DictOptions' |
|
3 |
|
|
4 |
export default function(Vue, options) { |
|
5 |
mergeOptions(options) |
|
6 |
Vue.mixin({ |
|
7 |
data() { |
|
8 |
if (this.$options === undefined || this.$options.dicts === undefined || this.$options.dicts === null) { |
|
9 |
return {} |
|
10 |
} |
|
11 |
const dict = new Dict() |
|
12 |
dict.owner = this |
|
13 |
return { |
|
14 |
dict |
|
15 |
} |
|
16 |
}, |
|
17 |
created() { |
|
18 |
if (!(this.dict instanceof Dict)) { |
|
19 |
return |
|
20 |
} |
|
21 |
options.onCreated && options.onCreated(this.dict) |
|
22 |
this.dict.init(this.$options.dicts).then(() => { |
|
23 |
options.onReady && options.onReady(this.dict) |
|
24 |
this.$nextTick(() => { |
|
25 |
this.$emit('dictReady', this.dict) |
|
26 |
if (this.$options.methods && this.$options.methods.onDictReady instanceof Function) { |
|
27 |
this.$options.methods.onDictReady.call(this, this.dict) |
|
28 |
} |
|
29 |
}) |
|
30 |
}) |
|
31 |
}, |
|
32 |
}) |
|
33 |
} |