Files
django-vue3-admin/web/src/utils/dictionary.ts
猿小天 197714e845 修复BUG:
1.修复settings中上传文件的bug;
2.优化字典展示
2023-12-01 17:31:37 +08:00

17 lines
440 B
TypeScript

import { toRaw } from 'vue';
import { DictionaryStore } from '/@/stores/dictionary';
/**
* @method 获取指定name字典
*/
export const dictionary = (name: string,key:string|number|undefined) => {
const dict = DictionaryStore()
const dictionary = toRaw(dict.data)
if(key!=undefined){
const obj = dictionary[name].find((item:any) => item.value === key)
return obj?obj.label:''
}else{
return dictionary[name]
}
}