当前位置:网站首页>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>
边栏推荐
- THREE.AxesHelper is not a constructor
- Telnet,SSH1,SSH2,Telnet/SSL,Rlogin,Serial,TAPI,RAW
- 分享一个通用的so动态库的编译方法
- Let's see through the network i/o model from beginning to end
- THREE. AxesHelper is not a constructor
- 一起看看matlab工具箱内部是如何实现BP神经网络的
- Share a general compilation method of so dynamic library
- 数据手册中的词汇
- 从零开始匹配vim(0)——vimscript 简介
- AcWing 345. 牛站 题解(floyd的性质、倍增)
猜你喜欢
Typical problems of subnet division and super network construction
454-百度面经1
Let's see through the network i/o model from beginning to end
Dark horse notes - exception handling
一起看看matlab工具箱内部是如何实现BP神经网络的
Gin 入门实战
Byte P7 professional level explanation: common tools and test methods for interface testing, Freeman
设置Wordpress伪静态连接(无宝塔)
LeetCode:1175. Prime permutation
Body mass index program, entry to write dead applet project
随机推荐
swiper组件中使用video导致全屏错位
hdu 4661 Message Passing(木DP&amp;组合数学)
Send template message via wechat official account
MySQL script batch queries all tables containing specified field types in the database
数据手册中的词汇
Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform
docker 方法安装mysql
Neon Optimization: an instruction optimization case of matrix transpose
分享一个通用的so动态库的编译方法
域分析工具BloodHound的使用说明
前置机是什么意思?主要作用是什么?与堡垒机有什么区别?
今日问题-2022/7/4 lambda体中修改String引用类型变量
Meet in the middle
ZOJ Problem Set – 2563 Long Dominoes 【如压力dp】
table表格设置圆角
AcWing 1148. 秘密的牛奶运输 题解(最小生成树)
HMM notes
shell脚本快速统计项目代码行数
Gazebo的安装&与ROS的连接
C # method of calculating lunar calendar date 2022