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

yf-tree-select

v1.1.1

Published

基于elementui的树形选择器

Downloads

1,109

Readme

yf-tree-select(树形下拉选择)

基于element-ui,el-tree-select的二次封装。

使用说明

安装

    npm install yf-tree-select -S

全局引入

    // main.js
    import YfTreeSelect from 'yf-tree-select'
    Vue.use(YfTreeSelect)

组件内引入

    import {YfTreeSelect} from 'yf-tree-select'
    components:{
        YfTreeSelect
    }

预览地址

Example

<template>
  <yf-tree-select
      v-model="selectValue"
      :tree-attrs="treeParams"
  />
</template>
<script>
  import {YfTreeSelect} from 'yf-tree-select'
  const data = [
    {name:'标签一',id:1,age:1},
    {name:'标签二',id:2,age:2},
    {
      name:'标签三',
      id:3,
      age:3,
      children:[
        {name:'标签三-一',id:31,age:31},
        {name:'标签三-二',id:32,age:41},
        {name:'标签三-三',id:33,age:51},
      ]
    },
  ]
  export default {
      components:{
        YfTreeSelect
      },
      data(){
        return {
          selectValue: [],
          treeParams: {
            data,
            filterable: true,
            props:{
              children: "children",
              label: "name",
              value: "id",
            }
          },
        }  
      },
  }
</script>

Attribute

| 参数 | 说明 | 类型 | 默认值 | |:---------------|:--------------------------------------------|:---------------------------|:-------| | v-model | 绑定值 | string/number/array/object | | | selectAttrs | select的属性 | object | 见下表 | | treeAttrs | tree的属性 | object | 见下表 | | customerFilter | 是否自定义过滤(默认标签名过滤),true配合_treeDataUpdateFun使用 | boolean | false | | foldLabels | 是否折叠labels | boolean | false | | onlyLeaf | 只能选择叶子节点 | boolean | false | | needValueName | 绑定值是否需要返回id和标签名(object) | boolean | false | | placement | 弹出框出现位置(el-popover参数) | string | bottom |

selectAttrs

| 参数 | 说明 | 类型 | 默认值 | |:------------|:------|:--------|:------| | placeholder | 占位符 | string | 请选择 | | disabled | 是否禁用 | boolean | false | | clearable | 是否可清空 | boolean | true |

其他与element-ui一致,可覆盖。 详情el-select

特殊说明

    :popper-append-to-body="false" // 固定false
    :filterable="false" // 固定false 改为弹出中搜索
    multiple // 根据v-model类型判断是否多选 string、number、object单选, array多选
    传入selectAttrs不会影响默认值,除非覆盖
    

treeAttrs

| 参数 | 说明 | 类型 | 默认值 | |:---------------------|:---------------------------------------------------|:--------|:------| | filterable | 是否展示搜索块 | boolean | false | | leafOnly | v-model是否只是叶子节点 | boolean | false | | includeHalfChecked | v-model是否包含半选节点 | boolean | false | | data | 展示数据 | array | | | props | 配置选项 | object | 见下表 |

props

| 参数 | 说明 | 类型 | 默认值 | |:---------|:-------------------------|:-------|:---------| | label | 指定节点标签为节点对象的某个属性值 | string | name | | children | 指定子树为节点对象的某个属性值 | string | children | | value | 指定节点id为节点对象的某个属性值 | string | value | | code | 如果有code,则标签显示为name(code) | string | |

其他与element-ui一致,可覆盖。 详情el-tree

特殊说明

    :show-checkbox="selectAttrs.multiple"  // 使用v-model值类型判断是否对树进行多项,取消对el-tree的人为传参show-checkbox
    :node-key="propsValue"  自动获取treeAttrs.props.value
    :draggable="false"      屏蔽拖动
    传入treeAttrs不会影响默认值,除非覆盖

方法

this.$refs.xxx.method

| 方法名 | 说明 | 参数 | |:--------------------------|:--------|:-------------| | _updatePopoverLocationFun | 更新弹出框位置 | | | _updateH | 更新弹出框宽度 | | | _treeDataUpdateFun | 更新树data | (data)接收一个数组 |

注意事项

    如果数据改变但是树没更新,使用this.$refs.xxx._treeDataUpdateFun手动更新

Events

| 时间名称 | 说明 | 回调参数 | |:-----------------|:----------|:----------------------------------------------------------------| | search-fun | 文本框输入内容触发 | 输入框的值 | | remove-tag | 删除标签触发 | 第一个参数是删除的id,第二个参数是删除的标签名(如果标签名有重复的可能会错,标签唯一才能获取到正确id,可配合code使用) | | select-clear | 清空输入框触发 | | | value-detail | 选中改变触发 | v-model的标签和标签id的数组对象 | | all-detail | 选中改变触发 | v-model的所有属性的数组对象 | | label-ids-detail | 标签改变触发 | 展示标签的数组对象 |