简体   繁体   中英

Vue+Firebase Conditional Rendering

I'm working through the Vue + Firebase. Each data on firebase, have isFinished: false/true statement. And I want to print isFinished: false datas. How can i print them with v-for? This is my code:

<tbody>
    <tr v-for="(item, index) in works" :key="index.id" class="list-table">
      <td id="checkbox-td" style="width: 24px">
        <span class="list-checkbox" @click="clickCheckbox(index, item)"></span>
      </td>
      <td>
        {{item.name}}
      </td>
      <td style="text-align: right;">
        {{item.username}}<br>
        <span style="font-size:10px;">{{item.date}} {{item.hour}}</span>
      </td>
    </tr>
  </tbody>

Wrap item with template and add v-for onto it:

  <tbody>
     <template v-for="(item, index) in works" :key="index.id">
    <tr  class="list-table" v-if="!item.isFinished">
      <td id="checkbox-td" style="width: 24px">
        <span class="list-checkbox" @click="clickCheckbox(index, item)"></span>
      </td>
      <td>
        {{item.name}}
      </td>
      <td style="text-align: right;">
        {{item.username}}<br>
        <span style="font-size:10px;">{{item.date}} {{item.hour}}</span>
      </td>
  </tr>
  </template>
</tbody>
<th>Finished</th>
<tbody> 
<tr v-for="(item, index) in works" :key="index.id" class="list-table">
<td data-label="Finished">{{item.isFinished? 'Finished' : 'Not Finished'}}</td>
</tr>
</tbody>

Add this to Your Table!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM