为了账号安全,请及时绑定邮箱和手机立即绑定

使用 Vue 过滤表列

使用 Vue 过滤表列

烙印99 2021-10-07 10:59:29
我已经成功地用 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,              },          }      },   
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 186 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信