组件介绍:
ba-tree-picker 是一款uniapp树形层级选择器插件,picker弹窗形式的,样式和比例参照uniapp的picker和uni-data-picker组件。
- 支持单选、多选、父级选择,当然也支持单层选择
- 支持Object对象属性自定义映射
- 支持显示全部选中、部分选中、未选中三种状态
- 支持快速自定义简单样式(分割线、按钮、标题、对齐等),深入样式可复写css
页面展示:
组件使用方法:
- 下载后的文件放到 components 下(代码地址:https://gitee.com/shi_xiao_chen/multiple-selection-in-dropdown.git)
- vue页面引入文件,并编写代码使用
import baTreePicker from "@/components/ba-tree-picker/ba-tree-picker.vue"
export default {
components: {
baTreePicker
}
3.在 script
中定义打开方法,和选择监听
methods: {
// 显示选择器
showPicker() {
this.$refs.treePicker._show();
},
//监听选择(ids为数组)
selectChange(ids, names) {
console.log(ids, names)
}
}
//在 template 中调用打开
<view @click="showPicker">调用选择器</view>
//listData放到data下的return中
listData = [
{
"value": "699791401616932870",
"label": "1",
"remark1": "42001",
"children": null
},
{
"value": "699791401616932871",
"label": "2",
"remark1": "42002",
"children": null
},
{
"value": "699791401616932872",
"label": "3",
"remark1": "42003",
"children": null
},
{
"value": "699791401616932873",
"label": "4",
"remark1": "42004",
"children": null
},
{
"value": "699791401616932874",
"label": "5",
"remark1": "42005",
"children": null
},
{
"value": "699791401616932875",
"label": "6",
"remark1": "42006",
"children": null
}
]
原组件借鉴地址:ba-tree-picker树形层级选择器(支持单选、多选、父级选择、映射) - DCloud 插件市场