You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
930 B
33 lines
930 B
import Dict from './Dict' |
|
import { mergeOptions } from './DictOptions' |
|
|
|
export default function(Vue, options) { |
|
mergeOptions(options) |
|
Vue.mixin({ |
|
data() { |
|
if (this.$options.dicts === undefined || this.$options.dicts === null) { |
|
return {} |
|
} |
|
const dict = new Dict() |
|
dict.owner = this |
|
return { |
|
dict |
|
} |
|
}, |
|
created() { |
|
if (!(this.dict instanceof Dict)) { |
|
return |
|
} |
|
options.onCreated && options.onCreated(this.dict) |
|
this.dict.init(this.$options.dicts).then(() => { |
|
options.onReady && options.onReady(this.dict) |
|
this.$nextTick(() => { |
|
this.$emit('dictReady', this.dict) |
|
if (this.$options.methods && this.$options.methods.onDictReady instanceof Function) { |
|
this.$options.methods.onDictReady.call(this, this.dict) |
|
} |
|
}) |
|
}) |
|
}, |
|
}) |
|
}
|
|
|