element的描述列表<el-descriptions>添加字典翻译功能

标题1

 可以利用对象赋值进行翻译功能:

HTML代码:

<el-descriptions border :column="2" direction="vertical">
 <el-descriptions-item label="单位类别">
          {{
            companyTypeFormat(viewForm.companyType?viewForm.companyType:'')
          }}
 </el-descriptions-item>
</el-descriptions>

标题2

 函数方法:(其中this.selectDictLabel方法,会写到下边"标题3")

函数代码:

methods: {
    //单位类别字典翻译
    companyTypeFormat(row, column) {
      return this.selectDictLabel(this.dict.type.DWLB, row.companyType);
    }
}

标题3

公共翻译方法(别忘了区mian.js全局注册)

Vue.prototype.selectDictLabel = selectDictLabel

// 回显数据字典
export function selectDictLabel(datas, value) {
  if (value === undefined) {
    return "";
  }
  var actions = [];
  Object.keys(datas).some((key) => {
    if (datas[key].value == ('' + value)) {
      actions.push(datas[key].label);
      return true;
    }
  })
  if (actions.length === 0) {
    actions.push(value);
  }
  return actions.join('');
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值