当前位置:网站首页>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>
边栏推荐
- Body mass index program, entry to write dead applet project
- 一起看看matlab工具箱内部是如何实现BP神经网络的
- Add the applet "lazycodeloading": "requiredcomponents" in taro,
- 2022 Google CTF SEGFAULT LABYRINTH wp
- 公钥\私人 ssh避password登陆
- THREE. AxesHelper is not a constructor
- Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which
- Dark horse notes - exception handling
- 【信号与系统】
- Google released a security update to fix 0 days that have been used in chrome
猜你喜欢

对C语言数组的再认识

Clickhouse fields are grouped and aggregated, and SQL is queried according to the granularity of any time period

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

1123. The nearest common ancestor of the deepest leaf node

The difference between Tansig and logsig. Why does BP like to use Tansig

修改px4飞控的系统时间

Go zero micro service practical series (IX. ultimate optimization of seckill performance)

Gazebo的安装&与ROS的连接

2022 Google CTF SEGFAULT LABYRINTH wp

Can the system hibernation file be deleted? How to delete the system hibernation file
随机推荐
C language instance_ four
ZOJ Problem Set – 2563 Long Dominoes 【如压力dp】
Metauniverse urban legend 02: metaphor of the number one player
安利一波C2工具
POJ 3177 Redundant Paths POJ 3352 Road Construction(双连接)
Neon Optimization: About Cross access and reverse cross access
Comparison of picture beds of free white whoring
【信号与系统】
Google released a security update to fix 0 days that have been used in chrome
让我们,从头到尾,通透网络I/O模型
Table table setting fillet
How to evaluate load balancing performance parameters?
Neon Optimization: summary of performance optimization experience
c语言—数组
字节P7专业级讲解:接口测试常用工具及测试方法,福利文
Transformation transformation operator
Taro applet enables wxml code compression
AI automatically generates annotation documents from code
curl 命令
736. Lisp 语法解析 : DFS 模拟题