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

@kunliu11/contextmenu

v1.0.0

Published

vue3右键菜单

Downloads

7

Readme

Vue3-ContextMenu

自定义菜单-vue3组件

特性

  1. 默认封装成Vue指令
  2. 支持自定义样式
  3. 支持子菜单
  4. 支持加入菜单图标
  5. 支持移动端长按唤出菜单(v1.7.0后支持)

配置

Props/指令Value (Object)

| 参数 | 说明 | 类型 | 可选值 | 默认值 | | ------------------- | ------------------------------------------------------------ | ------------------- | ------ | ------ | | el | 触发的Dom元素(以Vue组件方式或CustomMenu函数方式使用时必须传入) | - | - | - | | menuWidth | 菜单宽度 | Number | - | 240 | | menuList | 生成菜单项的数组,具体配置参考下表 | Array | - | - | | appendToBody | 容器是否挂载到body上 | Boolean | - | true | | injectCloseListener | 自动注入关闭菜单的Listener,设为false时需自行处理 | Boolean | - | true | | pos | 菜单弹框位置 | Object: () => {x,y} | | - |

menuList-菜单项数组配置

| 参数 | 说明 | 类型 | 可选值 | 默认值 | | ----------- | ------------------------------------------------------------ | ----------------- | ------ | ------ | | fn | 点击菜单后执行的回调,回调参数1为用户传入的Params, 参数2为点击右键时所在的HtmlElement元素(使用document.elementFromPoint获取), 参数3为指令绑定的当前元素, 参数4为原生点击事件数据 | Function | - | - | | label | 菜单名, 可使用函数,回调参数同fn选项 | String, Function | - | - | | border | 菜单单项是否展示下划线分割 | Boolean | - | false | | icon | 菜单图标的类名(字体图标) | String | - | - | | hidden | 菜单项是否隐藏,可使用函数,回调参数同fn选项 | Boolean, Function | - | - | | disabled | 菜单项是否不可点击,可使用函数,回调参数同fn选项 | Boolean, Function | - | - | | children | 子菜单的菜单项数组(配置与此表一致,但目前仅支持二级菜单) | Array | - | - | | line | 是否为分割线,该值为True时,以上设置均失效 | Boolean | - | - | | customClass | 注入自定义类名到MenuItem上 | String | - | - |

Methods

| 方法名 | 说明 | 参数 | | ------ | ---------------------------- | ----------------- | | show | 显示菜单,一般不需要自行调用 | x:number,y:number | | close | 关闭菜单 | - |

  1. 函数方式使用
<script lang="ts" setup>
import { ref } from 'vue'
import { ContextMenu } from 'vue3-contextmenu'
const domRef = ref()
const showContextmenu = (event: any, song: any) => {
  console.log(event, song)
  ContextMenu({
    el: domRef.value,
    menuList: [
    //具体的列表项
    ],
    menuWidth: 240,//列表官渡
    pos: {
      x: event.pageX,
      y: event.pageY
    }
  })
}
</script>
<template>
  <div ref="dom" @contextmenu.prevent.stop="showContextmenu($event, item)">Dom</div>
</template>

2.组件式使用