UNPKG

dwui

Version:

a part of wrapper on iView UI

32 lines (29 loc) 766 B
import ContextMenu from './context-menu.vue' ContextMenu.install = function (Vue) { Vue.component('context-menu', ContextMenu) Vue.prototype.$ContextMenu = function (e, root, tag, data, client) { // client 参数是用来区分是使用目标事件源的位置,通常使用offsetX, 但是edit-table右键菜单中发现需要使用clientX console.info(e) e.stopPropagation() e.preventDefault() let x = 0 let y = 0 if (client) { x = e.x y = e.y } else { x = e.offsetX y = e.offsetY } root.$emit('context-axis', { tag: tag, data: data, x: x, y: y }) } } if (typeof window !== 'undefined' && window.Vue) { window.Vue.use(ContextMenu) } export default ContextMenu