1.1.5 • Published 2 years ago

vue-contextmenu-next v1.1.5

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

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>

参数说明

  • 菜单参数

参数描述类型默认值必填
xX 坐标Number0
yY 坐标Number0
width菜单宽度String200px
height菜单高度Stringauto
itemHeight菜单项高度String40px
maxHeight菜单最大高度String500px
bgColor菜单背景颜色String#fff
hoverBgColor菜单项鼠标悬浮时背景颜色String#ecf5ff
hoverColor菜单项鼠标悬浮时字体颜色String#409eff
customLayoutClass菜单容器自定义类名String
customItemClass菜单项自定义类名String
menuList菜单项列表Array
  • 菜单项参数

参数描述类型默认值必填
text菜单项文本String
icon菜单项左侧图标StringCopyDocument
iconOption图标配置项(仅支持Ant Design Vue图标官方属性)Objectnull
renderKey菜单项渲染 keyString随机字符串
onClick菜单项点击事件Function
children菜单项子菜单String菜单项
1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago