v-if和v-else指令,以显示创建和更新的日期



我有一个django模型,它将创建和更新的日期存储在我的前端。我的vue标题中有一个名为date的标题。我正在显示创建的日期,但当对象更新时,我需要在同一标题下显示更新的日期。我有一个名为行的相同日期。updated_date_formated如果没有,我需要显示created_date,否则我需要显示更新日期

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

您可以使用Vue在v-text参数值中对逻辑进行编码。类似这样的东西:

<td v-text="row.updated_date_formatted != null ? row.updated_date_formatted : row.created_date_formatted"></td>

或者与Mustache语法相同:

<td>{{row.updated_date_formatted != null ? row.updated_date_formatted : row.created_date_formatted}}</td>

在这种情况下CCD_ 2 CCD_。

最新更新