代码优化
This commit is contained in:
@@ -2,11 +2,11 @@ import Vue from 'vue'
|
||||
import { get as getDictDetail } from '@/api/dictDetail'
|
||||
|
||||
export default class Dict {
|
||||
constructor (dict) {
|
||||
constructor(dict) {
|
||||
this.dict = dict
|
||||
}
|
||||
|
||||
async init (names, completeCallback) {
|
||||
async init(names, completeCallback) {
|
||||
if (names === undefined || name === null) {
|
||||
throw new Error('need dict names')
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import Dict from './Dict'
|
||||
|
||||
const install = function (Vue) {
|
||||
const install = function(Vue) {
|
||||
Vue.mixin({
|
||||
data () {
|
||||
data() {
|
||||
if (this.$options.dicts instanceof Array) {
|
||||
const dict = {
|
||||
dict: {},
|
||||
label: {},
|
||||
label: {}
|
||||
}
|
||||
return {
|
||||
dict,
|
||||
dict
|
||||
}
|
||||
}
|
||||
return {}
|
||||
},
|
||||
created () {
|
||||
created() {
|
||||
if (this.$options.dicts instanceof Array) {
|
||||
new Dict(this.dict).init(this.$options.dicts, () => {
|
||||
this.$nextTick(() => {
|
||||
@@ -22,7 +22,7 @@ const install = function (Vue) {
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user