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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue-contextmenu-next

v1.1.5

Published

使用 Vue3 + Ts 实现的轻量自定义右键菜单组件

Readme

Vue3 自定义右键菜单组件

最新版本说明

  • 支持自定义菜单项左侧图标,目前支持 ElementPlus、Ant Design Vue 中图标,如 CopyDocument,菜单项 icon 参数传 CopyDocument 即可。其中 Ant Design Vue图标支持官方属性配置,通过菜单项 iconOption 参数传入,具体可参考下方示例代码

效果图

效果图 效果图

安装

npm i vue-contextmenu-next

使用

<template>
  <button @contextmenu.prevent="handleContextMenu">
    右键按钮弹出自定义菜单
  </button>
</template>
<script lang="ts" setup>
import { $contextmenu } from "vue-contextmenu-next/index";

const handleContextMenu = ($event: MouseEvent) => {
  $contextmenu({
    x: $event.x,
    y: $event.y,
    menuList: [
      {
        text: "一级菜单",
        icon: "RedoOutlined",
        iconOption: {
          spin: true,
        },
        onClick: () => {},
        children: [
          {
            text: "二级菜单",
            icon: "AlarmClock",
            children: [
              {
                text: "三级菜单",
              },
            ],
          },
        ],
      },
      {
        text: "一级菜单",
        icon: "Apple",
        onClick: () => {},
      },
      {
        text: "一级菜单",
        icon: "List",
        onClick: () => {},
      },
    ],
  });
};
</script>
<style>
html,
body {
  width: 100vw;
  height: 100vh;
}
</style>

参数说明

  • 菜单参数

| 参数 | 描述 | 类型 | 默认值 | 必填 | | :---------------: | :----------------------: | :----: | :-----: | :--: | | x | X 坐标 | Number | 0 | 否 | | y | Y 坐标 | Number | 0 | 否 | | width | 菜单宽度 | String | 200px | 否 | | height | 菜单高度 | String | auto | 否 | | itemHeight | 菜单项高度 | String | 40px | 否 | | maxHeight | 菜单最大高度 | String | 500px | 否 | | bgColor | 菜单背景颜色 | String | #fff | 否 | | hoverBgColor | 菜单项鼠标悬浮时背景颜色 | String | #ecf5ff | 否 | | hoverColor | 菜单项鼠标悬浮时字体颜色 | String | #409eff | 否 | | customLayoutClass | 菜单容器自定义类名 | String | 无 | 否 | | customItemClass | 菜单项自定义类名 | String | 无 | 否 | | menuList | 菜单项列表 | Array | 无 | 是 |

  • 菜单项参数

| 参数 | 描述 | 类型 | 默认值 | 必填 | | :-------: | :------------: | :------: | :-----------: | :--: | | text | 菜单项文本 | String | 无 | 是 | | icon | 菜单项左侧图标 | String | CopyDocument | 否 | | iconOption | 图标配置项(仅支持Ant Design Vue图标官方属性) | Object | null | 否 | | renderKey | 菜单项渲染 key | String | 随机字符串 | 否 | | onClick | 菜单项点击事件 | Function | 无 | 否 | | children | 菜单项子菜单 | String | 菜单项 | 否 |