标签:ons sele 对象 子节点 dep str 显示 default sel
/** itemArr:菜单项 targetSelector:指定显示上下文菜单的区域type:string:#id,.className等 **/ const useContextMenu = (itemArr, targetSelector, deps) => { let clickedNode = {} const menu = new Menu() itemArr.forEach(item => { menu.append(new MenuItem(item)) }) const handler = (e) => { // 区域限定 //e.targets是否时document.querySelector(targetSelector)的子节点 if (document.querySelector(targetSelector).contains(e.target)) { clickedNode.current = e.target e.preventDefault() menu.popup({ window: remote.getCurrentWindow() }) } } window.addEventListener(‘contextmenu‘, handler) //右击鼠标时触发执行 handler }
标签:ons sele 对象 子节点 dep str 显示 default sel
原文地址:https://www.cnblogs.com/baixinL/p/14274709.html