vue 右键 单击 事件

1. 去掉浏览器默认事件,添加自定义事件

     @contextmenu.prevent="show()"  //show 为自定义事件

上代码:

   

<button type="button" class="btn btn-primary" @contextmenu.prevent="show()">保存</button>

自定义方法:

methods:{ 
show:function(){
      alert("触发了右击事件");
    },
}

Ok!!!

猜你喜欢

转载自blog.csdn.net/weixin_41472431/article/details/89640799