admin
2024-08-28 c2e92c3bd4fc134b27ba6a6271f63b032b2b9d99
提交 | 用户 | 时间
e57a89 1 import Dict from './Dict'
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 }