学无先后,达者为师

网站首页 编程语言 正文

在el-table中判断三种情况,显示不同的数据

作者:南极一块修炼千年的大冰块 更新时间: 2023-10-26 编程语言

后端传来的数据是数据0,1,2。0代表未支付,1代表支付宝支付,2代表微信支付,要求动态显示在表格中

 <el-table-column align="center" prop="pay_method" label="支付方式" width="150">
        <template slot-scope="{row: {pay_method}}">
          <span v-if="+pay_method === 1">支付宝</span>
          <span v-else-if="+pay_method === 2">微信</span>
          <span v-else>未支付</span>
        </template>
      </el-table-column>

知识点

  • slot-scope="{row: {pay_method}}" 相当于把scope分解出来了pay_nethod,后面直接使用即可
    +pay_method,把pay_method转为数字进行全等比较,不使用用==是为了避免出错

原文链接:https://blog.csdn.net/weixin_42557996/article/details/95663194

  • 上一篇:没有了
  • 下一篇:没有了
栏目分类
最近更新