1.0.14 • Published 4 years ago

@lxw15337674/v-context-menu v1.0.14

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

v-contextMenu

基于vue的右键菜单组件

特性

- 集成v-hotkey,支持功能快捷键

用法

  1. 安装插件
npm i @lxw15337674/v-context-menu
  1. 注册为全局组件
import contextMenu from '@lxw15337674/v-context-menu'
Vue.use(contextMenu, 'g');

或者按需引用

import {contextItem,contextMenu} from '@lxw15337674/v-context-menu';

export default {
    name: 'App',
    components: { contextItem,contextMenu },
}
  1. demo
    <contextMenu>
            <div class="content">
              本体内容
            </div>
            <template slot="contextMenu">
                <context-item
                    v-for="menuItem in contextMenu"
                    :key="menuItem.label"
                    :hotkey="menuItem.hotkey"
					:divided="menuItem.divided"
                    :disabled="menuItem.disabled"
                    :callback="menuItem.callback"
                    :hotkey="menuItem.hotkey"
                >
                </context-item>
            </template>
        </contextMenu>

data: function () {
        return {
            contextMenu: [
                {
                    label: '显示',
                    callback: () => {
                        console.log('显示');
                    },
                    hotkey: 'enter',
                    disabled: true,
                },
                {
                    label: '粘贴',
                    callback: () => {
                        console.log('粘贴');
                    },
                    hotkey: 'ctrl+v',
                },
            ],
        };
    },

context-menu

菜单主题

组件props参数

参数说明类型是否必填可选值默认值
disabled是否禁用菜单Booelantrue/falsefalse

组件事件

参数说明回调参数
show菜单显示时触发
close菜单关闭时触发

context-item

菜单项

组件props参数

参数说明类型是否必填可选值默认值举例
label菜单项标题String/Number
hotkey功能快捷键Stringctrl+c
callback回调函数Function
divided是否在上方添加分隔符Booleantrue/falsefalse
disabled是否禁用Booleantrue/falsefalse
autoHide被点击后菜单是否自动隐藏Booleantrue/falsefalse

组件事件

参数说明回调参数
click被点击时触发的事件当前元素实例、点击事件
1.0.14

4 years ago

1.0.13

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago