当前位置:网站首页>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>
边栏推荐
- Clickhouse fields are grouped and aggregated, and SQL is queried according to the granularity of any time period
- 1123. The nearest common ancestor of the deepest leaf node
- 各种语言,软件,系统的国内镜像,收藏这一个仓库就够了: Thanks-Mirror
- 黑马笔记---创建不可变集合与Stream流
- C language instance_ five
- Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which
- Add the applet "lazycodeloading": "requiredcomponents" in taro,
- Set up [redis in centos7.x]
- Spark TPCDS Data Gen
- 字节P7专业级讲解:接口测试常用工具及测试方法,福利文
猜你喜欢
Let's see through the network i/o model from beginning to end
Clickhouse fields are grouped and aggregated, and SQL is queried according to the granularity of any time period
LeetCode. 剑指offer 62. 圆圈中最后剩下的数
1123. The nearest common ancestor of the deepest leaf node
子网划分、构造超网 典型题
Installation of gazebo & connection with ROS
Make Jar, Not War
Send template message via wechat official account
MySQL script batch queries all tables containing specified field types in the database
Instructions for using the domain analysis tool bloodhound
随机推荐
Gin 入门实战
ZOJ Problem Set – 2563 Long Dominoes 【如压力dp】
各种语言,软件,系统的国内镜像,收藏这一个仓库就够了: Thanks-Mirror
Taro2.* applet configuration sharing wechat circle of friends
Neon Optimization: an optimization case of log10 function
系统休眠文件可以删除吗 系统休眠文件怎么删除
剑指 Offer II 035. 最小时间差-快速排序加数据转换
免费白嫖的图床对比
THREE.AxesHelper is not a constructor
What are the differences between Oracle Linux and CentOS?
uva 1401 dp+Trie
Metauniverse urban legend 02: metaphor of the number one player
Installation and testing of pyflink
Machine learning: the difference between random gradient descent (SGD) and gradient descent (GD) and code implementation.
Neon Optimization: performance optimization FAQ QA
Amway wave C2 tools
对C语言数组的再认识
c语言—数组
Realize incremental data synchronization between MySQL and ES
今日问题-2022/7/4 lambda体中修改String引用类型变量