vue 鼠标右击

鼠标右击事件

@contextmenu.stop  //  阻止事件冒泡
@contextmenu.prevent  //  阻止原生事件触发
@node-contextmenu  // el-tree 中右击事件
@click.right // 右击事件

                <div class="head-container" @contextmenu.stop.prevent="">
                    <el-tree
                        :data="deptOptions"
                        :props="defaultProps"
                        :expand-on-click-node="false"
                        :filter-node-method="filterNode"
                        ref="tree"
                        default-expand-all
                        @node-click="handleNodeClick"
                        @node-contextmenu="handleNodeClickRight"
                    />
                </div>
            <div @contextmenu.stop.prevent="">
                <span @click.right="handleNodeClickRight">123</span>
            </div>
                
  methods: {
    // 节点单击事件
    handleNodeClick (data) {
      console.log(data)
    },
    // 节点右击事件
    handleNodeClickRight (e) {
      console.log(e)
    }
  }

两种方式鼠标右击菜单

插件使用

Vue 1分钟实现右键菜单,懒人的福音
在这里插入图片描述

源码

一个鼠标右键插槽的菜单
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值