Vue根据后端返回结果转换成不同的展示效果的三种方式

方式一:

      <el-table-column 
        prop="tagType" 
        label="标签类型" 
        width="120"
        :formatter="tagTypeFormatter">
      </el-table-column>
tagTypeFormatter(row) {
      let tagType = row.tagType;
      if (tagType === '0') {
        return '情况1';
      } else if (tagType === '1') {
        return '情况2';
      }
    }

 方式二:

<el-table-column prop="type" label="类型" align="center">
    <template v-slot="{ row }">
        <span v-show="row.type == 1">普通用户</span>
        <span v-show="row.type == 2">管理员</span>
        <span v-show="row.type == 3">项目经理</span>
    </template>
</el-table-column>

方式三:

      <el-table-column prop="tagClass" label="标签分类" width="120">
        <template slot-scope="scope">
          <span>{{ classFormat(scope.row.tagClass, getTagClass) }}</span>
        </template>
      </el-table-column>
      getTagClass: [
        { dictValue: '01', dictLabel: '政策因素' },
        { dictValue: '02', dictLabel: '用电行为因素' },
        { dictValue: '03', dictLabel: '线损状态' },
        { dictValue: '04', dictLabel: '技术因素' },
        { dictValue: '05', dictLabel: '运行指标因素' },
        { dictValue: '06', dictLabel: '客户服务' },
        { dictValue: '07', dictLabel: '台区设备' },
        { dictValue: '08', dictLabel: '地理环境' }
      ]
    classFormat(row, obj) {
      let filter = obj.filter(res => res.dictValue === row);
      return filter[0]?.dictLabel;
    },

posted @   JamieChyi  阅读(608)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示