首页 > 其他分享 >将后端返回的数字转为文字显示在页面上

将后端返回的数字转为文字显示在页面上

时间:2022-09-19 14:14:33浏览次数:61  
标签:返回 name level value ces 转为 等级 页面

方式一:页面自定义
html

  <span>{{level[ces.level]}}</span>

ts

  level = {
    1: '等级1',
    2: '等级2',
    3: '等级3',
  }
  ces = {
    level: 1,
    name: 等级测试
  }

方式二:字典自定义
html

  <span>{{level[ces.level]}}</span>

ts

  level = {};
  this.level = _.keyBy(_.cloneDeep(levelList), "value");
  // ==> {
            "1": {"name": "等级1","value": "1"},
            "2": {"name": "等级2","value": "2"},
            "3": {"name": "等级3","value": "3"}
	}

字典

  levelList = [
    { name: "等级1", value: "1" },
    { name: "等级2", value: "2" },
    { name: "等级3", value: "3" },
  ];

标签:返回,name,level,value,ces,转为,等级,页面
From: https://www.cnblogs.com/jingyiyi/p/16707497.html

相关文章