You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用v-if和v-else指令在Vue中展示Django模型的创建/更新日期

实现Vue表格列动态显示创建/更新日期

你可以通过Vue的三元表达式实现这个逻辑,直接修改v-text的绑定值即可:

<template slot="row" slot-scope="{ row, index }">
  <td v-text="row.updated_date_formatted ? row.updated_date_formatted : row.created_date_formatted"></td>
</template>

逻辑说明

  • 当row.updated_date_formatted不为空时,单元格显示更新日期
  • 仅当row.updated_date_formatted为空(对象未被更新过)时,显示创建日期

内容的提问来源于stack exchange,提问作者Happy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 09:50:30