1024programmer Blog Vue—-right-click pop-up menu (vue-contextmenu)_vue right-click pop-up menu_VIVI Xiao’s blog

Vue—-right-click pop-up menu (vue-contextmenu)_vue right-click pop-up menu_VIVI Xiao’s blog

class=”markdown_views prism-atom-one-dark”>

Requirements: Right-click, pop-up menu, query information, find vue-contextmenu.
Project address: https://github.com/chIIC/vue-contextmenu
Insert picture here  Description
Installation:

npm install vue-contextmenu --save
 

Introduction:

import VueContextMenu from 'vue-contextmenu'
 Vue.use(VueContextMenu)
 

Use:

template
 div id="app" @contextmenu="showMenu"
     style="width: 100px;height: 100px;margin-top: 20px;background: red;">
     <vue-context-menu :contextMenuData="contextMenuData"
         @home="home"
         @deletedata="deletedata"/vue-context-  menu>
 /div
 /template
 script
 export default {
     
   name: 'app',
   data () {
     
     return {
     
     // menu data
        contextMenuData: {
     
          menuName: 'demo',
          //The position where the menu is displayed
          axis: {
     
            x: null,
            y: null
          },
          //menu options
          menulists: [{
     
            fnHandler: 'home', //binding event
            icoName: 'fa fa-home fa-fw', //icon icon
            btnName: 'Back to the home page' //menu name
          }, {
     
              fnHandler: 'deletedata',
              icoName: 'fa fa-minus-square-o fa  -fw',
              btnName: 'Delete Layout'
          }]
        }
   },
   methods: {
     
     showMenu () {
     
         event.preventDefault()
         var x = event.clientX
         var y = event.clientY
         // Get the current location
       this.contextMenuData.axis = {
     
         x, y
       }
     },
     home () {
     
       alert("home page")
     },
     deletedata () {
     
       console.log('delete!')
     }
   }
 }
 /script
 

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/vue-right-click-pop-up-menu-vue-contextmenu_vue-right-click-pop-up-menu_vivi-xiaos-blog/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索