0.1.1 • Published 5 years ago

kr-filter v0.1.1

Weekly downloads
33
License
-
Repository
-
Last release
5 years ago

advanced-filter

安装

npm install kr-filter

引入

main.js

import KrFilter from "kr-filter";
import "kr-filter/lib/kr-filter.css";
Vue.use(krFilter);

demo.vue

<template>
  <div id="app">
    <krFilter :config="tagTable" @doFilter="search" />
  </div>
</template>

Attributes

参数说明类型默认值
config配置项Array[]
separator多选状态下参数间的分隔符String;

Events

事件名称说明回调参数
doFilter点击筛选时触发导出的筛选参数(Object)

Config 参数详解

参数示例:

[
  {
    key: "type",
    content: "类型",
    multiple: true,
    type: "select",
    separator: "QQQ",
    color: "red",
    background: "#0f0faa",
    options: [
      {
        label: "类型1",
        value: "type1"
      },
      {
        label: "类型2",
        value: "type2"
      }
    ]
  },
  {
    key: "status",
    content: "状态",
    multiple: false,
    type: "select",
    options: [
      {
        label: "状态1",
        value: "status1"
      },
      {
        label: "状态2",
        value: "status2"
      }
    ]
  },
  {
    key: "keyword",
    content: "关键字",
    type: "input"
  },
  {
    key: "dateRange",
    content: "日期范围",
    type: "dateRange",
    multiple: false
  },
  {
    key: "date",
    content: "日期",
    type: "date",
    multiple: true
  }
];

参数说明:

config 数组中,每一个 object 都代表要配置的可供选择的参数项,object 中参数具体解析如下:

config:
事件名称说明类型可选值
key筛选参数的 key 值(必须唯一)String
content该参数展示在组件上的名称String
type筛选项类型String"select","input","date","dateRange"
multiple是否多选Booleantrue、false (默认 false)
separator多选时多个值之间的分隔符(仅在多选时有效)String在未指定时使用外部传入的 attribute 中公共的 separator 参数
options下拉选项(仅在 type 为"select"时可用)Array
color标签字体颜色(不设定则取用默认颜色)String
background标签背景色(不设定则取用默认颜色)String
type:
类型名称说明
select单选、多选类型筛选项,需配置 options 参数
input输入类型参数
date日期类型参数
dateRange日期范围类型参数
options:

options 仅在 type 为 select 类型的选项中可用:

示例:
options: [
  {
    label: "状态1",
    value: "status1"
  },
  {
    label: "状态2",
    value: "status2"
  }
];
参数说明
label该选项展示的文字
value选项的值
0.1.1

5 years ago

0.1.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago