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

@liuyunxi/tree

v1.1.0

Published

树形 vue3+ts

Downloads

4

Readme

树形 YxTree

代码演示

<template>
    <div style="width: 240px">
        <YxTree
            ref="YxTreeRef"
            @on-drop="onDrop"
            @add="add"
            @edit="edit"
            @remove="remove"
            @click="click"
        ></YxTree>
    </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'

const YxTreeRef = ref()
/*拖动结束*/
const onDrop = (treeNodes: any, targetNode: any, moveType: any) => {
    console.log(treeNodes, targetNode, moveType)
}
/*添加*/
const add = (params: any) => {
    console.log(params)
}
/*编辑*/
const edit = (params: any) => {
    console.log(params)
}
/*删除*/
const remove = (params: any) => {
    console.log(params)
}
/*点击*/
const click = (params: any) => {
    console.log(params)
}

onMounted(() => {
    /**
     * open:true, 默认打开 默认false
     * edit:false,禁止编辑 默认true
     * del:false,禁止删除 默认true
     * add:false,禁止添加子节点 默认true
     * drag:false 禁止拖拽 默认true
     * dropInner:false ,禁止拖入内部, 默认true
     * dropRoot:false ,禁止成为跟节点 默认true
     * childOuter:false,子节点禁止拖走  默认true
     */
    const zNodes = [
        {
            id: 0,
            pId: -1,
            name: '固定不变的根节点',
            open: true,
            edit: false,
            remove: false,
            icon: '/icon1.png',
        },
        { id: 1, pId: 0, name: '父节点1 - 展开', open: true, icon: '/icon1.png' },
        {
            id: 11,
            pId: 1,
            name: '父节点11 - 折叠',
            dropRoot: false,
            dropInner: false,
            childOuter: false,
            icon: '/icon1.png',
        },
        { id: 111, pId: 11, name: '叶子节点111', dropInner: false, icon: '/icon3.png' },
        { id: 112, pId: 11, name: '叶子节点112', dropInner: false, icon: '/icon3.png' },
        { id: 113, pId: 11, name: '叶子节点113', dropInner: false, icon: '/icon2.png' },
        { id: 114, pId: 11, name: '叶子节点114', dropInner: false, icon: '/icon3.png' },
        { id: 12, pId: 1, name: '父节点12 - 折叠', icon: '/icon1.png' },
        { id: 121, pId: 12, name: '叶子节点121', icon: '/icon1.png' },
        { id: 122, pId: 12, name: '叶子节点122', icon: '/icon1.png' },
        { id: 123, pId: 12, name: '叶子节点123', icon: '/icon1.png' },
        { id: 124, pId: 12, name: '叶子节点124' },
        { id: 13, pId: 1, name: '父节点13 - 没有子节点', isParent: true, icon: '/icon1.png' },
        { id: 2, pId: 0, name: '父节点2 - 折叠' },
        { id: 21, pId: 2, name: '父节点21 - 展开', open: true, icon: '/icon1.png' },
        { id: 211, pId: 21, name: '叶子节点211' },
        { id: 212, pId: 21, name: '叶子节点212' },
        { id: 213, pId: 21, name: '叶子节点213' },
        { id: 214, pId: 21, name: '叶子节点214' },
        { id: 22, pId: 2, name: '父节点22 - 折叠', icon: '/icon1.png' },
        { id: 221, pId: 22, name: '叶子节点221' },
        { id: 222, pId: 22, name: '叶子节点222' },
        { id: 223, pId: 22, name: '叶子节点223' },
        { id: 224, pId: 22, name: '叶子节点224' },
        { id: 23, pId: 2, name: '父节点23 - 折叠', icon: '/icon1.png' },
        { id: 231, pId: 23, name: '叶子节点231' },
        { id: 232, pId: 23, name: '叶子节点232' },
        { id: 233, pId: 23, name: '叶子节点233' },
        { id: 234, pId: 23, name: '叶子节点234' },
        { id: 3, pId: 0, name: '父节点3 - 没有子节点', isParent: true },
    ]
    YxTreeRef.value.init(zNodes, { drag: true, add: true, edit: true, remove: true })
    setTimeout(() => {
        YxTreeRef.value.select('0')
    }, 1000)
})
</script>

<style scoped lang="less"></style>

API

树形 YxTree

事件

| 事件名称 | 说明 | 回调参数 | |---------|-----|----------------------------------------------------------| | on-drop | 拖动 | function(treeNodes: any, targetNode: any, moveType: any) | | add | 添加 | function(treeNode) | | edit | 编辑 | function(treeNode) | | remove | 删除 | function(treeNode) | | click | 点击 | function(treeNode) |

方法

| 事件名称 | 说明 | 回调参数 | |------|-----|-----------------------------------------------------------------------| | init | 初始化 | function(zNodes, { drag: true, add: true, edit: true, remove: true }) |

方法参数说明

| 参数 | 说明 | 类型 | 默认值 | |--------|--------|:-----------------:|-------| | zNodes | 简单数据 | {id:,pId,name...} | | | drag | 是否允许拖动 | boolean | false | | add | 是否开启添加 | boolean | true | | edit | 是否开启编辑 | boolean | true | | remove | 是否开启删除 | boolean | true |