当前位置:网站首页>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>
边栏推荐
- The difference between Tansig and logsig. Why does BP like to use Tansig
- [chip scheme design] pulse oximeter
- 2022 Google CTF SEGFAULT LABYRINTH wp
- HMM 笔记
- 域分析工具BloodHound的使用说明
- 免费白嫖的图床对比
- hdu 4661 Message Passing(木DP&amp;组合数学)
- go-zero微服务实战系列(九、极致优化秒杀性能)
- Installation and testing of pyflink
- AcWing 1148. 秘密的牛奶运输 题解(最小生成树)
猜你喜欢

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

AI automatically generates annotation documents from code

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

2022 Google CTF SEGFAULT LABYRINTH wp

According to the analysis of the Internet industry in 2022, how to choose a suitable position?

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

Instructions for using the domain analysis tool bloodhound

Dark horse notes - create immutable sets and streams

黑马笔记---创建不可变集合与Stream流

Transformation transformation operator
随机推荐
今日问题-2022/7/4 lambda体中修改String引用类型变量
Neon Optimization: an instruction optimization case of matrix transpose
Spark TPCDS Data Gen
7.6模拟赛总结
Set up [redis in centos7.x]
The MySQL database in Alibaba cloud was attacked, and finally the data was found
机器学习:随机梯度下降(SGD)与梯度下降(GD)的区别与代码实现。
C language instance_ five
Dark horse notes - create immutable sets and streams
C语言实例_2
拖拽改变顺序
AcWing 361. 观光奶牛 题解(spfa求正环)
DS-5/RVDS4.0变量初始化错误
Clickhouse fields are grouped and aggregated, and SQL is queried according to the granularity of any time period
一起看看matlab工具箱内部是如何实现BP神经网络的
POJ 3177 Redundant Paths POJ 3352 Road Construction(双连接)
HMM notes
AcWing 1140. 最短网络 (最小生成树)
Docker method to install MySQL
docker 方法安装mysql