鼠标右击事件
@contextmenu.stop
@contextmenu.prevent
@node-contextmenu
@click.right
<div class="head-container" @contextmenu.stop.prevent="">
<el-tree
:data="deptOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
default-expand-all
@node-click="handleNodeClick"
@node-contextmenu="handleNodeClickRight"
/>
</div>
<div @contextmenu.stop.prevent="">
<span @click.right="handleNodeClickRight">123</span>
</div>
methods: {
handleNodeClick (data) {
console.log(data)
},
handleNodeClickRight (e) {
console.log(e)
}
}
两种方式鼠标右击菜单
插件使用
Vue 1分钟实现右键菜单,懒人的福音
源码
一个鼠标右键插槽的菜单