iView Table表格带搜索功能的Table组件

原文地址声明:https://blog.csdn.net/qq_23179075/article/details/79939244

iview-filter-table

一个基于iView Table 的带搜索过滤的Table组件, 支持 Input输入框 和 Select下拉框两种表格筛选方式.

在这里插入图片描述

使用

模板

<filter-table @on-search="onSearch"
              :data="users"
              :columns="tableColumns">
</filter-table>

列描述数据对象:

tableColumns: [
  {
    title: '用户名',
    key: 'username',
    filter: {
      type: 'Input' //输入框过滤
    }
  },
  {
    title: '状态',
    key: 'status',
    filter: {
      type: 'Select',//下拉框过滤
      option: userStatus //下拉框选项数据对象
    }
  }
]

下拉框选项数据格式:

  const userStatus = {
    0: {
      value: 0,
      name: '全部'
    },
    1: {
      value: 1,
      name: '已锁定',
      color: 'red'
    },
    2: {
      value: 2,
      name: '正常',
      color: 'green'
    },
  };

触发搜索事件:

onSearch(search) {
  //模拟数据库查询数据
  //这个search应该是传到后台,然后台来根据条件查询数据库
  alert('查询条件:'+JSON.stringify(search,null,4));
}

在该方法中进行条件过滤,更新组件 data 属性的值。

直接运行该项目可以看当前组件的Example效果。
在这里插入图片描述

Project setup

yarn install

Compiles and hot-reloads for development

yarn run serve

Compiles and minifies for production

yarn run build

Run your tests

yarn run test

Lints and fixes files

yarn run lint

Customize configuration

See Configuration Reference.

Github源码地址:https://github.com/azhengyongqin/iview-filter-table

  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 10
    评论
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值