当前位置:网站首页>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>
边栏推荐
- docker 方法安装mysql
- Amway wave C2 tools
- Installation of gazebo & connection with ROS
- Yunna | work order management software, work order management software app
- Typical problems of subnet division and super network construction
- 2022 Google CTF SEGFAULT LABYRINTH wp
- Taro2.* applet configuration sharing wechat circle of friends
- 公钥\私人 ssh避password登陆
- Taro中添加小程序 “lazyCodeLoading“: “requiredComponents“,
- 域分析工具BloodHound的使用说明
猜你喜欢

Yunna | work order management software, work order management software app

移植DAC芯片MCP4725驱动到NUC980

云呐-工单管理制度及流程,工单管理规范

Yunna - work order management system and process, work order management specification

454-百度面经1

The difference between Tansig and logsig. Why does BP like to use Tansig
![JS reverse -- ob confusion and accelerated music that poked the [hornet's nest]](/img/40/da56fe6468da64dd37d6b5b0082206.png)
JS reverse -- ob confusion and accelerated music that poked the [hornet's nest]

字节P7专业级讲解:接口测试常用工具及测试方法,福利文

从底层结构开始学习FPGA----FIFO IP的定制与测试

【信号与系统】
随机推荐
AI automatically generates annotation documents from code
Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform
Instructions for using the domain analysis tool bloodhound
从底层结构开始学习FPGA----FIFO IP的定制与测试
AcWing 1141. 局域网 题解(kruskalkruskal 求最小生成树)
Sword finger offer II 035 Minimum time difference - quick sort plus data conversion
云呐|工单管理软件,工单管理软件APP
Add the applet "lazycodeloading": "requiredcomponents" in taro,
ClickHouse字段分组聚合、按照任意时间段粒度查询SQL
Neon Optimization: performance optimization FAQ QA
Clickhouse fields are grouped and aggregated, and SQL is queried according to the granularity of any time period
Yunna | work order management software, work order management software app
[signal and system]
Case development of landlord fighting game
2022 Google CTF SEGFAULT LABYRINTH wp
Start from the bottom structure to learn the customization and testing of fpga---- FIFO IP
AI 从代码中自动生成注释文档
DS-5/RVDS4.0变量初始化错误
图片打水印 缩放 和一个输入流的转换
How to evaluate load balancing performance parameters?