0.0.3 • Published 3 years ago

vue-virtual-selcet v0.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

vue-virtual-selcet

一个vue2的虚拟列表选择器(virtual-select)

demo.gif

1.安装

npm install vue-virtual-selcet

2.注册

import virtualSelcet from "vue-virtual-selcet";
Vue.use(virtualSelcet);

3.使用

<template>
  <virtual-selcet
    v-model="val"
    style="width: 300px"
    @change="change"
    :options="options"
    placeholder="请选择"
    :filterMethod="filterMethod"
  />
</template>

Attributes

参数说明类型默认值
optionsselect的选项,例:{value:"值",label:"标签"}Array[]
placeholder占位符string请选择
filterable是否可搜索booleantrue
filter-method自定义搜索方法functionfunction(val, optionList) { return optionList.filter((item) => item.label.toLowerCase().indexOf(val.toLowerCase()) == -1 ? false : true ); }
data-key每个options数据对象中获取的唯一键,它的值必须是唯一,且类型为数字或者字符串string | functionfunction (option) { return option.value; }

Events

事件名称说明回调参数
change选中值发生变化时触发目前的选中值
blur当 input 失去焦点时触发(event: Event)
focus当 input 获得焦点时触发(event: Event)