美文网首页
iView Table表格带搜索功能的Table组件

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

作者: 飞渡浮舟 | 来源:发表于2018-04-12 18:02 被阅读5543次

    请注明出处: https://blog.csdn.net/qq_23179075/article/details/79939244

    [图片上传失败...(image-9342de-1523682905237)]
    [图片上传失败...(image-da4ca4-1523682905237)]
    [图片上传失败...(image-165b55-1523682905237)]
    [图片上传失败...(image-67d26c-1523682905237)]
    [图片上传失败...(image-92ce57-1523682905237)]
    [图片上传失败...(image-c8f980-1523682905237)]

    这里写图片描述
    博主是个前端小白,不会写 CSS 样式, 所以在做公司项目的时候, 页面都是用的第三方 UI 库. 随着前端 Vue.js 崛起, 支持 Vue2.0 的前端 UI 库也非常多. 比如下面这几个.
    • Muse-UI

    http://www.muse-ui.org/#/index

    • Element UI

    http://element.eleme.io/#/zh-CN

    • iView

    https://www.iviewui.com/

    目前公司做后台采用的是第三个 iView , 可是在用到这个库的 Table 组件的时候发现他的表格搜索过滤不完整, 用起来也不好用. 所以博主试着在它的 Tab 基础上做一些扩展. 最后的效果如下:

    filterTable.gif

    支持 Input输入框 和 Select下拉框两种表格筛选方式.

    使用

    模板

        <filter-table @load="loadData" //过滤触发事件
                      :data="users"
                      :columns="tableColumns"
                      :search="search" //过滤的条件
                      >
        </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'
        },
      };
    

    Github源码地址
    [图片上传失败...(image-e3f9e-1523682905237)]

    相关文章

      网友评论

          本文标题:iView Table表格带搜索功能的Table组件

          本文链接:https://www.haomeiwen.com/subject/mdjfkftx.html