项目页面需要自定义鼠标右键菜单栏可以用下面的代码:
当然布局和样式都可以从新写,根据需要改动即可
html:
<ul class="contextmenu" v-show="rightmouse">
<li>刷新</li>
<li>关闭</li>
<li>关闭其它</li>
<li>关闭所有</li>
</ul>
js:
table_rightmouse(){
event.preventDefault();
this.rightmouse = true;
var rbox = document.getElementsByClassName("contextmenu")[0];
rbox.style.left = event.clientX + 'px';
rbox.style.top = event.clientY - 40 + "px";
},
css:
.contextmenu {
margin: 0;
background: #fff;
width: 100px;
z-index: 100;
position: absolute;
list-style-type: none;
padding: 5px 0;
border-radius: 4px;
font-size: 12px;
font-weight: 400;
color: #333;
box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, .3)
}
.contextmenu li {
margin: 0;
padding: 7px 16px;
cursor: pointer;
}
.contextmenu li:hover {
background: #eee;
}