npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

adv-selection

v0.0.1

Published

下拉组件

Downloads

1

Readme

基于Vue的下拉组件

版本修改

包含组件

  1. Selection组件,下拉框和基本视图,作用同select
  2. SelectionOption组件,下拉选项,作用同option
  3. FocusPanel组件,下拉面板。点击Selection组件展开下拉面板,面板中包含SelectionOption。 点击下拉组件以外的区域,面板关闭,用的是焦点丢失原理,而不是简单点的点击事件。 因为当页面上存在iframe,对iframe内部的文档点击的事件是不可在一个文档对象中监听的。 焦点事件监听部分依赖zepto.js(jquery.js亦可)。

props属性

| 属性名 | 类型 | 说明 | 默认值 | | :-- | :-- | :-- | :-- | | value | ArrayObject | 根据默认规则自动生成下拉选项Array:[{valueFiled: 值, labelField: 显示的文本}...]Object:{key:value ...}。自定义下拉选项的话参见默认的slot | 无 | | value-field | String | 自动生成下拉遍历value中的数据时识别用作value字段的标识 | value | | label-field | String | 自动生成下拉遍历value中的数据时识别用作显示下拉文本字段的标识 | label | | model | String | 设置下拉选中数据的格式"pair": {valueFiled, labelField}"value": valueField"label": labelField | pair | | default-index | Number | 默认选中下拉的第几个选项,索引从0开始 | 无 | | placeholder | String | 没有选中项时的提示文字 | 无 | | multiple | Boolean | 是否可以多选 | false | | disabled | Boolean | 是否禁用 | false | | filterable | Boolean | 是否可以搜索 | true | | filter-method | Function(keywords, callback) | 开启搜索功能后,自定义搜索方法。把搜索结果传入callback参数中,格式和value一致 | 内置根据输入关键字过滤下拉项的方法 | | filter-placeholder | String | 搜索框显示的文字提示 | 请输入关键字 | | filter-delay | Number(毫秒) | 搜索动作太过频繁,设置延时时间 | 300 | | clearable | Boolean | 单选模式下是否可以清空下拉选项多选模式下在最后出现一个叉叉一次性清除所有选中项 | false | | eq | Function(a,b):Boolean | 比较下拉控件的value是否相等,默认采用 === 的方式。对于复杂的value格式,比如{value: 1}和{value: 1},[1]和[1],在程序上是不相等的,但在业务逻辑上可能视为相等。需要重写判断的方法 | function(a,b){return a===b} |

事件

| 事件名 | 说明 | 回调参数 | | :-- | :-- | :-- | | on-change | 选中项发生改变,一般是手动操作改变 | 1、所有选中的value值;2、所有选中的文本 | | on-value-change | 选中的value发生变化时触发(只要数据发生改变就触发) | 1、所有选中的value值;2、所有选中的文本 |

slots

| 名称 | 说明 | | :-- | :-- | | 默认 | 下拉选项如果props中的value生成的下拉项不足以满足需求,可以自己实现下拉内容。推荐使用配套的selection-option组件,否则下拉项不能正确的响应功能事件 |

selection-option组件

| props | 类型 | 说明 | | :-- | :-- | :-- | | value | Object | 下拉选项的value | | label | String | 下拉选项的文本,不使用属性字段可以直接使用slot |