Skip to content

peng-tree 树形选择器

peng-tree (tki-tree) 是一个树形选择组件,支持单选/多选、父子节点联动。

基础用法

vue
<template>
  <peng-tree 
    ref="tkitree" 
    :range="treeData" 
    idKey="id" 
    nameKey="name" 
    multiple 
    @confirm="onConfirm"
  >
  </peng-tree>
  <button @tap="showTree">打开选择器</button>
</template>

<script>
export default {
  data() {
    return {
      treeData: [
        { id: 1, name: '节点1', children: [{ id: 11, name: '子节点11' }] }
      ]
    }
  },
  methods: {
    showTree() {
      this.$refs.tkitree._show();
    },
    onConfirm(list) {
      console.log('已选节点:', list);
    }
  }
}
</script>

Props

参数说明类型默认值
range树形数据源Array[]
idKeyID 字段名String'id'
nameKey名称字段名String'name'
multiple是否开启多选Booleanfalse
selectParent父节点是否可被选择Booleanfalse
title标题String''
confirmColor确定按钮颜色String'#07bb07'
cancelColor取消按钮颜色String'#757575'

Methods

方法名说明参数
_show显示选择器-
_hide隐藏选择器-

Events

事件名说明回调参数
confirm点击确定时触发(selectedList: Array)
cancel点击取消时触发-