在前端对返回字段进行dict关联

81 阅读1分钟
<template>
  <a-table
    :columns="columns"
    :dataSource="dataSource"
    ></a-table>
</template>
<script>
  export default {
  	data() {
      dataSource: [],
      dictOptions: {},
    	columns: [
        {
            title: '用户名称',
            align: 'left',
            dataIndex: 'username',
            customRender: (text) => (text ? filterMultiDictText(this.dictOptions['username'], text) : ''),
          },
      ]
    }

    methods: {
      initDictConfig() {
      initDictOptions('user, realname, username').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'username', res.result)
        }
      });
   	 }
  	}
</script>