2.0.2 • Published 2 years ago

td-contextmenu v2.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

自定义右键菜单

TOC

参数

参数说明类型可选值默认值
options参数object{ el, data, beforeShow, shown, beforeHide, hidden, beforeDestroy, destroyed }

options说明

参数

参数说明类型可选值默认值
el元素节点和样式节点的idstringmycontextmenu
data自定义菜单结构数据array

事件

事件名说明参数
beforeShow显示前的回调函数event
shown显示后的回调函数event
beforeHide隐藏前的回调函数event
hidden隐藏后的回调函数event
beforeDestroy销毁前的回调函数
destroyed销毁后的回调函数

事件

事件名说明参数
setData设置菜单结构数据array
removeMenu清空菜单结构数据
show显示右键菜单
hide隐藏右键菜单
destroy销毁组件

使用

CDN引入

<script src="https://unpkg.com/td-contextmenu/lib/index.min.js"></script>
let contextmenu = new TdContextMenu({
    el: "mycontextmenu",
    data: [
        [
            {
                icon: "",
                title: "复制",
                func: null,
            },
            {
                icon: "",
                title: "粘贴",
                func: null,
            },
            {
                icon: "",
                title: "剪切",
                func: null,
            }
        ],
        [
        	{
                icon: "",
                title: "移动",
                func: null,
            	children: [
                    [
                        {
                            icon: "",
                            title: "上移",
                            func() {
                                console.log("开始上移")
                                // ...
                            },
                        },
                        {
                            icon: "",
                            title: "下移",
                            func: null,
                        }
                    ]
                ]
            }  
        ]
    ],
    beforeShow(e) {
        console.log("显示前的回调");
    },
    shown(e) {
        console.log("显示后的回调");
    },
    beforeHide(e) {
        console.log("隐藏前的回调");
    },
    hidden(e) {
        console.log("隐藏后的回调");
    },
    beforeDestroy() {
        console.log("销毁前的回调");
    },
    destroyed() {
        console.log("销毁后的回调");
    }
})

image-20220126183215533

更新: npm version patch npm publish

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago