| 123456789101112131415161718192021222324252627282930313233343536 |
- import { getDict } from '@/api/toConsult.js'
- export default {
- data() {
- return {
- //字典['dict_type']
- dicts:[]
- }
- },
- created() {
- /** 组件中设置dictType,即可获取相应的value*/
- if(this.dicts && this.dicts.length > 0){
- this.dicts.forEach(item=>{
- this.getDictHandler(item,(res)=>{
- this[item] = res
- })
- })
- }
- },
- methods: {
- //根据字典类型获取字典值
- getDictHandler(dictType,callBack) {
- getDict( dictType ).then(res => {
- let { code, data, msg } = res
- if (code == 200) {
- callBack(data)
- }
- })
- }
- //组件使用方法参考下边注释
- // this.getDictHandler('core_check_type',res=>{
- // console.log(res);
- // })
- }
- }
|