vue-div形式下翻译字典值

1、主页面标题对应列

<div class="myToDoListNoticeTitle" @click="handleNoticeView(item)">{{item.noticeTitle}}</div>

在这里插入图片描述

2、点击标题查看详情操作

2.1、主方法

   /** 点击标题查看详情操作 */
    handleNoticeView(row) {
      this.reset();
      const noticeId = row.noticeId || this.ids
      getNotice(noticeId).then(response => {
        this.form = response.data;
        this.form.noticeType = this.dictValueLabelMap[this.form.noticeType]
        this.openNotice2 = true;//打开弹框
        this.title = "公告详情";
      });
    },

2.2、computed中的dictValueLabelMap方法

  /** dictValueLabelMap方法,根据传入的dictValue返回对应的dictLabel */
  computed: {
    dictValueLabelMap(){
      return this.typeOptions.reduce((acc, curr) => {
        acc[curr.dictValue] = curr.dictLabel;
        return acc;
      }, {});
    }
  },

2.3、created中的获取字典值

  created() {
    this.getDicts("sys_notice_type").then(response => {
      this.typeOptions = response.data;
    });
  }

2.4、记录点

(1)this.form.noticeType = this.dictValueLabelMap[this.form.noticeType]:为了翻译字典值,this.dictValueLabelMap详细介绍在2.2代码
(2)this.typeOptions来源:对应2.3代码

3、弹框代码和页面

<el-dialog :title="title" :visible.sync="openNotice2" width="700px" append-to-body>
      <div style="height: 400px;">
        <div class="noticeTitle"  v-html="form.noticeTitle"></div>
        <div class="noticeContainer">
          <div class="noticeBox" v-html="form.createTime"></div><span class="noticeType">|</span>
          <span class="noticeType">类型:</span>
          <div class="noticeBox" v-html="form.noticeType"></div>
        </div>
        <hr>
        <div class="noticeContent" v-html="form.noticeContent"></div>
      </div>
    </el-dialog>

在这里插入图片描述

3.1、记录点

(1)append-to-body:为了避免出现遮罩层在最上面挡住了显示层,以及被其他定位元素挡住(主要IE浏览器)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值