当前位置:网站首页>Right mouse button customization
Right mouse button customization
2022-07-07 01:35:00 【Ah Liu】

1. Right click the page that needs to be added , binding contextmenu event ( Block browser default Events , Add custom events )
<xx Components @contextmenu.prevent.native="openMenu($event)">
2. Write the contents of the right-click menu on the page
<ul
v-show="visible"
:style="contextmenuStyle"
class="contextmenu"
>
<li @click="setBack">
On the ground floor
</li>
<li @click="setTop">
Put on top
</li>
</ul>
3. Define attribute variables
private contextmenuStyle: any={
}
private visible=false;
4. Create a listening event , To trigger the method of closing the right-click menu
@Watch('visible')
private visibleChange () {
if (this.visible) {
// On display Add a click event Used to hide the contents of the right key
window.addEventListener('click', this.closeMenu);
} else {
window.removeEventListener('click', this.closeMenu);
}
}
5. Two methods to open and close the right-click menu
// Right mouse button
private async openMenu (e) {
this.contextmenuStyle = {
left: e.offsetX + 'px',
top: e.offsetY + 'px'
};
this.visible = true;
}
private setBack () {
this.drawer.sendToBack();
}
private setTop () {
this.drawer.setTop();
}
private closeMenu () {
this.visible = false;
}
6. style
<style lang='scss' scoped>
@import '[email protected]/css/variable';
.contextmenu {
margin: 0;
background: #eeeded;
opacity: 0.9;
z-index: 3000;
position: absolute;
list-style-type: none;
padding: 5px;
border-radius: 4px;
font-size: 12px;
color: #505050;
border: 1px solid $color-border;
box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.3);
}
.contextmenu li {
margin: 0;
padding: 2px 10px;
border-radius: 2px;
cursor: pointer;
}
.contextmenu li:hover {
background: $color-button-disabled-hover;
color: $color-basic;
}
</style>
边栏推荐
- Taro2.* applet configuration sharing wechat circle of friends
- JTAG principle of arm bare board debugging
- 736. Lisp 语法解析 : DFS 模拟题
- 黑马笔记---异常处理
- 安全保护能力是什么意思?等保不同级别保护能力分别是怎样?
- Dark horse notes - create immutable sets and streams
- The MySQL database in Alibaba cloud was attacked, and finally the data was found
- 字节P7专业级讲解:接口测试常用工具及测试方法,福利文
- Transplant DAC chip mcp4725 to nuc980
- 移植DAC芯片MCP4725驱动到NUC980
猜你喜欢

ClickHouse字段分组聚合、按照任意时间段粒度查询SQL

shell脚本快速统计项目代码行数

Byte P7 professional level explanation: common tools and test methods for interface testing, Freeman

Can the system hibernation file be deleted? How to delete the system hibernation file

LeetCode. 剑指offer 62. 圆圈中最后剩下的数

AcWing 1148. 秘密的牛奶运输 题解(最小生成树)

云呐|工单管理办法,如何开展工单管理

AcWing 361. 观光奶牛 题解(spfa求正环)

Let's see through the network i/o model from beginning to end

第三方跳转网站 出现 405 Method Not Allowed
随机推荐
Yunna - work order management system and process, work order management specification
C language instance_ two
AcWing 344. 观光之旅题解(floyd求无向图的最小环问题)
POJ 3177 Redundant Paths POJ 3352 Road Construction(双连接)
设置Wordpress伪静态连接(无宝塔)
云呐|工单管理软件,工单管理软件APP
Appium自动化测试基础 — uiautomatorviewer定位工具
移植DAC芯片MCP4725驱动到NUC980
从零开始匹配vim(0)——vimscript 简介
7.6模拟赛总结
Today's question -2022/7/4 modify string reference type variables in lambda body
JTAG principle of arm bare board debugging
7.6 simulation summary
curl 命令
Telnet,SSH1,SSH2,Telnet/SSL,Rlogin,Serial,TAPI,RAW
HMM notes
AI automatically generates annotation documents from code
Failed to successfully launch or connect to a child MSBuild. exe process. Verify that the MSBuild. exe
系统休眠文件可以删除吗 系统休眠文件怎么删除
Appium基础 — Appium Inspector定位工具(一)