请教下element ui 表格中的prop 根据后台返回的 Status 来显示不同的状态,应该怎么操作呢

查了下,有相关的问题,关键是我这个是基于element ui 表格中的prop来进行判断的,这就懵逼了。。。
如何应用的prop中 这个是关键。。
0是未确认
1是已确认

<el-table-column
              prop="orderStatus"
              label="订单状态"
              width="">

clipboard.png

clipboard.png

clipboard.png

阅读 13.9k
6 个回答

谢邀!你的意思有点不明确!
你的意思是这样根据字段改表头?如果是就像下面代码那样写!

<el-table-column
          prop="orderStatus"
          label="订单状态"
          width=""
          v-if='orderStatus===0'
          >
            </el-table-column>
<el-table-column
          prop="orderStatus"
          label="订单XXX状态"
          width=""
          v-if='orderStatus===1'
          >
            </el-table-column>

如果是根据字段改内容,就像下面代码那样写!

    <el-table-column label="订单状态" width="">
                <template scope="scope">
                    <a href="javascript:;">{{scope.row.orderStatus===0?'已完成订单':'未完成订单'}}</a>
                </template>
            </el-table-column>
  • 按照我的理解,你是要自定义这一列的值,如果是0显示未确认,1显示已确认

  • 参考:http://element.eleme.io/#/en-...

  • 以下为代码:

<el-table-column label="订单状态">
    <template scope="scope">
        {{ scope.row.orderStatus ? '已确认' : '未确认' }}
    </template>
</el-table-column>

假如同样的问题<el-table-column label="状态">

<template scope="scope">
    {{ scope.row.orderStatus ? '已发布' : '未发布' }}
</template>

</el-table-column> 如果发布了 发不了几次 怎么实现呢图片描述

推荐一个多种状态的写法

<el-table-column label="售后类型" width="80">
<template scope="scope">

<span>{{[ "已发布", "未发布" ,"仅退款" ,"补发货" ,"维修服务" ,"安装" ][scope.row.orderStatus]}}</span>

</template>
</el-table-column>

状态 不是索引的写法

<span>{{
({"A":"天猫","E":"京东","F-APP":"自主商场", "F-SG":"自主商场", "F-PDD":"自主(拼多多)", "F-TM":"自主(天猫)","F-JD":"自主(京东)"}[scope.row.orderStatus])
}}</span>

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题