博客
关于我
vue 拖拽及右键菜单
阅读量:550 次
发布时间:2019-03-09

本文共 1155 字,大约阅读时间需要 3 分钟。

1、拖拽 vue.draggable 安装

cnpm i -S vuedraggable

2、拖拽 vue.draggable 引用

3、 e-vue-contextmenu 安装

npm install --save e-vue-contextmenu@latest

4、e-vue-contextmenu 引用

import Contextmenu from ‘e-vue-contextmenu’Vue.use(Contextmenu)

5、使用

@contextmenu.prevent="rightClick($event)"  必须放在循环的div上

HTML代码

//拖拽事件
{ { item.authName}}
<阻止右键菜单(浏览器行为),右键执行函数show>
{ { item.authName}}
//右键事件
关闭其他
关闭左侧
关闭右侧

js 代码

methods: {       onStart() {         this.drag = true;    },    //拖拽结束事件    onEnd() {         this.drag = false;    }	    //右键事件 获取dom元素打开菜单    rightClick(e) {         this.$refs.ctxshow.showMenu(e);    },    //关闭其他    other() {         console.log(this.index1);      this.$store.commit("closeOther", this.index1);      this.$refs.ctxshow.hideMenu(); // 隐藏菜单    },    //关闭左侧    closeLeft() {         this.$store.commit("closeLeft", this.index1);      this.$refs.ctxshow.hideMenu(); // 隐藏菜单    },    //关闭右侧    closeRight() {         this.$store.commit("closeRight", this.index1);      this.$refs.ctxshow.hideMenu(); // 隐藏菜单    },  }

效果

在这里插入图片描述

转载地址:http://iiliz.baihongyu.com/

你可能感兴趣的文章
Netty 的 Handler 链调用机制
查看>>
Netty 编解码器和 Handler 调用机制
查看>>
Netty 编解码器详解
查看>>
Netty 解决TCP粘包/半包使用
查看>>
Netty 调用,效率这么低还用啥?
查看>>
Netty 高性能架构设计
查看>>
Netty+Protostuff实现单机压测秒级接收35万个对象实践经验分享
查看>>
Netty+SpringBoot+FastDFS+Html5实现聊天App详解(一)
查看>>
netty--helloword程序
查看>>
netty2---服务端和客户端
查看>>
Netty5.x 和3.x、4.x的区别及注意事项(官方翻译)
查看>>
netty——bytebuf的创建、内存分配与池化、组成、扩容规则、写入读取、内存回收、零拷贝
查看>>
netty——Channl的常用方法、ChannelFuture、CloseFuture
查看>>
netty——EventLoop概念、处理普通任务定时任务、处理io事件、EventLoopGroup
查看>>
netty——Future和Promise的使用 线程间的通信
查看>>
netty——Handler和pipeline
查看>>
Vue输出HTML
查看>>
netty——黏包半包的解决方案、滑动窗口的概念
查看>>
Netty中Http客户端、服务端的编解码器
查看>>
Netty中使用WebSocket实现服务端与客户端的长连接通信发送消息
查看>>