Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

iview-contextmenu

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iview-contextmenu

A contextmenu component depend on iview-dropdown component

  • 0.2.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

iview-contextmenu

version NPM download license

A contextmenu component depend on iview-dropdown component.

Demo

demo

Engilsh | 中文

Install

Using npm:

npm install iview-contextmenu

Usage

main.js:

import Vue from 'vue'
import iView from 'iview'
import Contextmenu from 'iview-contextmenu'

import 'iview/dist/styles/iview.css'
import 'iview-contextmenu/dist/iview-contextmenu.css'

Vue.use(iView)
Vue.use(Contextmenu)

App.vue:

<template>
  <div
    id="app"
    @contextmenu.prevent="preventContextmenu"
  >
    <!-- It will respond to document contextmenu event when no set trigger = 'custom' -->
    <Contextmenu
      :menu-data="menuData"
      @on-select="handleSelect"
      @on-cancel="handleCancel"
    ></Contextmenu>
  </div>
</template>

<script>
export default {
  name: 'App',
  data () {
    return {
      menuData: [
        {
          title: 'Menu1',
          name: 'menu1'
        },
        {
          title: 'Menu2',
          name: 'menu2',
          shortcut: 'Ctrl+J'
        },
        {
          title: 'Menu3',
          name: 'menu3',
          divided: true,
          disabled: true
        }
      ]
    }
  },
  methods: {
    handleSelect (name) {
      console.log(`select contextmenu: ${name}`)
    },
    handleCancel () {
      console.log('cancel contextmenu')
    },
    preventContextmenu () {
      return false
    }
  }
}
</script>

<style>
* {
  box-sizing: border-box;
}
html, body {
  height: 100%;
}
body {
  overflow: hidden;
}
#app {
  height: 100%;
}
</style>

Props

PropertyDesciptionTypeDefault
menu-dataAn Array that generates the contextmenu.Array-
triggerSet to 'custom' to control visible manually.String''
visibleControl the display of Contextmenu manually, used when trigger = 'custom'.Booleanfalse

Events

Event NameDescriptionReturn Value
on-selectEmit when clicking the contextmenu item, the return value will be 'parentName-childName' when clicking the child menu.ContextmenuItem's prefixName
on-cancelTriggered when click the outside body.-

Params

KeyDescriptionTypeDefault
titleItem's title.String-
nameUsed to tag the item.String-
visibleUsed to hidden the item.Booleantrue
dividedShow spilt line.Booleanfalse
desabledUsed to disable the item.Booleanfalse
iconRight icon Type, it will be ignored when item has children.String-
shortcutRight text content, it wiil be ignored when right icon is set or item has children.String-
childrenThe son itemArray-
prefixPrefix the children name when to select item's children, default used name value when no setString-

License

MIT

Copyright (c) 2019-present, iview-contextmenu

Keywords

FAQs

Package last updated on 06 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc