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

后端传来的数据是数据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转为数字进行全等比较,不使用用==是为了避免出错

猜你喜欢

转载自blog.csdn.net/weixin_42557996/article/details/95663194
今日推荐