我已經成功地用 Vue 構建了一個表,它有下拉列表作為每列的標題。每個下拉列表的值來自不同的 axios 調用作為數組,并且它們被正確填充。我遇到的問題是,第二次我過濾任何列時,它隱藏了整個表,并且無法重置它以將其恢復。所以它根本沒有正確過濾,也沒有回到“全部顯示”選項。我在這里做錯了什么:<table style="width:100%; text-align:center;"> <thead> <tr> <th> <select v-model="filters.resource"> <option v-for="resource in resources" :value="resource">{{ resource.name }}</option> </select> </th> <th> <select v-model="filters.location"> <option v-for="location in locations" :value="location">{{ location.name }}</option> </select> </th> <th></th> <th> <select v-model="filters.status"> <option v-for="status in statuses" :value="status">{{ status }}</option> </select> </th> <th></th> </tr> </thead> <tbody v-for="event in filtered"> <tr> <td>{{ event.resource }}</td> <td>{{ event.location }}</td> <td>{{ event.status }}</td> </tr> </tbody> </table> <script> export default { data () { return { events: [], locations: [], resources: [], filters: { title: null, resource: null, location: null, status: null, }, } },
使用 Vue 過濾表列
烙印99
2021-10-07 10:59:29