dongnunai3125 2019-05-11 13:02
浏览 57

有没有办法在桌面上只显示特定数据? 比如在数据库中收到的数据是否包含'SuperAdmin'而不显示它?

I already get all the data from the database and displayed it on my vue component. But, how can I display specific data on the table? Like if the results from the database contains a user type of 'SuperAdmin' I wanted to filter it like don't display if you find data related 'SuperAdmin'

https://imgur.com/kwTziOG - Here is my output.

I have searched this kind of problem and nothings pops-up.

Say for example.

['Paul','paul@new.com',['Admin']

['Paul', 'paul@new.com', ['SuperAdmin']

I just want to display the first array. Since it doesn't have a user type of SuperAdmin.

<tr v-for="user in users.data" :key="user.id">
<td>{{user.id}}</td>
<td>{{user.name}}</td>
<td>{{user.email}}</td>
<td>{{user.type}}</td>
<td>{{user.created_at |myDate}}</td>
<td>
    <a href="#" @click="editModal(user)">
        <i class="fa fa-edit"></i>
    </a>
            /
    <a href="#" @click="deleteUser(user.id)">
        <i class="fa fa-trash red"></i>
    </a>

</td>
</tr>

I just displayed all the data being fetch in the database. Just wanted it to filter it somehow.

  • 写回答

1条回答 默认 最新

  • dongyi9484 2019-05-11 13:12
    关注

    I have not used Vue in alittle while but if I remember correctly you can just use 'v-if' and it will conditionally render the data. Below is an example of how this could be done.

    Possible Solution

    <tr v-for="user in users.data" :key="user.id">
    <div v-if="user.type == 'SuperAdmin'">
    <td>{{user.id}}</td>
    <td>{{user.name}}</td>
    <td>{{user.email}}</td>
    <td>{{user.type}}</td>
    <td>{{user.created_at |myDate}}</td>
    <td>
        <a href="#" @click="editModal(user)">
            <i class="fa fa-edit"></i>
        </a>
        <a href="#" @click="deleteUser(user.id)">
            <i class="fa fa-trash red"></i>
        </a>
    </td>
    </div>
    </tr>
    

    Hope this answered your question, good luck!

    评论

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本