需要在区域内右击自定义菜单的DIV绑定contextmenu右击事件

<div   style="width:100% ; z-index: inherit;position: relative;margin:0 auto ;" align="center"  @contextmenu.prevent="rightClick">

<img  :src="dialogImg" style="width: 100%; " >

<div  :style="dialogPos.style" align="center" >{{dialogPos.position}}</div>

<div  :style="dialogPos.styleT" align="center" ></div>

</div>

触发rightClick方法

rightClick(MouseEvent) { // 鼠标右击触发事件

this.menuVisible = false; // 先把模态框关死,目的是 第二次或者第n次右键鼠标的时候 它默认的是true

this.menuVisible = true ; // 显示模态窗口,跳出自定义菜单栏

var menu = document.querySelector('#menu');

menu.style.left = MouseEvent.clientX-160 + 'px';

document.addEventListener('click', this.foo); // 给整个document添加监听鼠标事件,点击任何位置执行foo方法

menu.style.top = MouseEvent.clientY-100 + 'px'

},

foo() { // 取消鼠标监听事件 菜单栏

this.menuVisible = false;

document.removeEventListener('click', this.foo) // 要及时关掉监听,不关掉的是一个坑,不信你试试,虽然前台显示的时候没有啥毛病,加一个alert你就知道了

},

右键菜单模态框

<div v-show="menuVisible">

<ul id="menu" class="menu">

<a><li class="menu__item" style="margin-top: 3px;"  @click="JumpcarDynamicQuery">检索1</li></a>

<a><li class="menu__item"  @click="JumpcarCarStaticQuery">检索2</li></a>

<a><li class="menu__item"  @click="JumpDynamicQuery">检索3</li></a>

<a><li class="menu__item"  @click="JumpcarPasserDynamicQuery">检索4</li></a>

</ul>

</div>

右键菜单样式

.menu__item {

display: block;

line-height: 20px;

text-align: center;

/*margin-top: 10px;*/

}

.menu {

height: 85px;

width: 90px;

position: absolute;

border-radius: 10px;

border: 1px solid #999999;

background-color: #f4f4f4;

z-index: 99999;

padding-inline-start: 0px;

}

这样就可以啦。

VUE 鼠标右键自定义的更多相关文章

  1. js实现鼠标右键自定义菜单(弹出层),并与树形菜单(TreeView)、iframe合用(兼容IE、Firefox、Chrome)

    <table class="oa-el-panel-tree"> <tr> <td style="vertical-align: top; ...

  2. jQuery自定义Web页面鼠标右键菜单

    jQuery自定义Web页面鼠标右键菜单 右键菜单是固定的,很多时候,我们需要自定义web页面自定义菜单,指定相应的功能. 自定义的原理是:jQuery封装了鼠标右键的点击事件(“contextmen ...

  3. JavaScript自定义鼠标右键菜单

    下面为JavaScript代码 window.onload = function () { //好友列表 var f = 0; //判断指定id的元素在页面中是否存在 if (document.get ...

  4. 自定义鼠标右键(层叠式菜单:cascading menu)

    Author:KillerLegend From:http://www.cnblogs.com/killerlegend/p/3575391.html Date:Tuesday, February 1 ...

  5. 自定义鼠标右键(层叠式菜单:cascading menu)(文件系统右键、文件夹系统右键和桌面鼠标右键)

    转载:http://www.cnblogs.com/killerlegend/p/3575391.html 转载:http://www.cnblogs.com/shouce/p/5101001.htm ...

  6. JQuery模拟网页中自定义鼠标右键菜单

    题外话.......最近在开发一个网站项目的时候,需要用到网页自定义右键菜单,在网上看了各路前辈大神的操作,头晕目眩,为了达到目的,突然灵机一动,于是便有了这篇文章. 先放个效果图(沾沾自喜,大神勿喷 ...

  7. JavaScript 自定义html元素鼠标右键菜单

    自定义html元素鼠标右键菜单 实现思路 在触发contextmenu事件时,取消默认行为(也就是阻止浏览器显示自带的菜单),获取右键事件对象,来确定鼠标的点击位置,作为显示菜单的left和top值 ...

  8. Vue 监听鼠标左键 鼠标右键以及鼠标中键修饰符click.left&contextmenu&click.middle

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. js自定义鼠标右键菜单

    document.oncontextmenu = function(e) { return false; } document.onmousedown = function(e) { switch(e ...

随机推荐

  1. MySQL连接池详解

    使用场景数据库连接是一种关键的.有限的.昂贵的资源,这一点在多用户的网页应用程序中体现得尤为突出.对数据库连接的管理能显著影响到整个应用程序的伸缩性和健壮性,影响到程序的性能指标.数据库连接池正是针对 ...

  2. 找不到方法:'System.Net.Http.HttpRequestMessage System.Web.Http.Controllers.HttpActionContext.get_Request()'

    出现这种情况一般是引用了.net standard 库解决方案1:在web.config 文件中增加如下节点 <dependentAssembly> <assemblyIdentit ...

  3. nmon +java nmon Alalizy agent 动态交互监控

    下载地址:1. Download and install nmon. - for linux platform, you can download form: http://nmon.sourcefo ...

  4. 路飞-pip源

    pip安装源 介绍 """ 1.采用国内源,加速下载模块的速度 2.常用pip源: -- 豆瓣:https://pypi.douban.com/simple -- 阿里: ...

  5. CSS学习(8)盒模型

    box:盒子,每个元素在页面中都会生成一个矩形区域(盒子) 盒子类型: 1.行盒,display属性=inline的元素,不换行(默认值) 2.块盒,display属性=block的元素,换行 浏览器 ...

  6. 【Python collections】

    目录 namedtuple deque Counter OrderedDict defaultdict "在内置数据类型(dict.list.set.tuple)的基础上,collectio ...

  7. mysql开启远程访问及相关权限控制

    开启mysql远程访问: 授予用户user 密码 passwd 所有权限 所有主机IP可访问 授权语句:Grant <权限> on 表名[(列名)] to 用户 With grant op ...

  8. winform 多个datagridview 之间同步滚动

    1.添加Scroll事件 2.注意需判断数据长度,避免溢出 private void dgYY_Scroll(object sender, ScrollEventArgs e) { ) { dgFee ...

  9. SSHException: Error reading SSH protocol banner

    当我在使用ssh  远程connect 另一台机器的server 时出现了错误,错误如下,起初以为是自己代码写的有问题,后来本地了一下看了跑的没问题,我就开始根据报错去查寻原因, 起初在论坛博客看到这 ...

  10. CF1208G Polygons 数论

    题目链接:https://codeforces.com/contest/1208/problem/G 题意:给定两个正整数\(n\)和\(k\),询问在一个圆上你最少需要几个点,才能在这些点上构造出\ ...