1 Star 18 Fork 7

Yunter丶 / customSelect

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

layui下拉选择器

示例:

演示地址:演示地址

1.单选

示例1

  1. 多选

示例2

介绍:

基于layui.tree的树形下拉选择组件,支持单选和多选,目前为输入框触发下拉事件,已选值将填入到input中。

用法:

layui.use(['customSelect'], function() {
    const select = layui.customSelect
    select.render({
        el: 'example',
        data: list,
        checkbox: true,
        checked: function (obj) {
            
        }
    })
})

参数:

参数名 描述 默认值 说明
el layui下拉选择器的根节点dom的id 必填
data 下拉树的数据 必填,每项数据须有title/name/text之一 树形多维数据或一维数组,参照layui.tree
type 类型 null 若是单选类型,值为'radio'
line 连接线 true 参照layui.tree
accordion 是否开启手风琴模式 false 参照layui.tree
checked 回调函数 function 下面有说明

根节点DOM示例:

  <input autocomplete="off" id="example" type="text" class="layui-input" placeholder="快速查找" />

数据示例(data):

title: '江西',
    id: 1,
    children: [{
        title: '南昌',
        id: 2,
        children: [{
            title: '高新区', //三级菜单
            id: 3,
            children: [{
                title: '12121', //三级菜单
                id: 9
            }]
            //…… //以此类推,可无限层级
        }]
    }]
}, {
    title: '陕西', //一级菜单
    id: 4,
    children: [{
        title: '西安', //二级菜单
        id: 5
    }]
}]

回调:

checked: function(obj, checkedDatas, {values, idents, datas}) {
  // 返回一个对象,有以下三个成员
  // 1、obj 点击某个复选框时的数据、选中状态和dom元素
  // 2、checkedDatas 每次点击复选框时的已被选中数据,单选时为[null]
  // 3、Object {
    // vaule 所有选中数据的title
    // idents 所有选中数据的id
    // datas 所有的选中数据
    // 三个数据都是一维数组
  }
}

更新

2021-4-16 使用input作为节点,传入input的节点ID即可

MIT License Copyright (c) 2021 Yunter丶 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于layui.tree的树形下拉选择组件,支持单选和多选。 展开 收起
JavaScript 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/YUN73R/customSelect.git
git@gitee.com:YUN73R/customSelect.git
YUN73R
customSelect
customSelect
master

搜索帮助