michitaro / vue-menu

Menu/Contextmenu Component for vue2
https://michitaro.github.io/vue-menu/
MIT License
263 stars 26 forks source link

Programmatic open the context menu. #28

Open liudonghua123 opened 4 years ago

liudonghua123 commented 4 years ago

I want to open a dynamic context menu programmatic in the right click event handler of a button or component. How can I achieve this?

miyoosan commented 3 years ago

well, you can do it with ref's method. first, use vue-menu anywhere like this: `

` second, you can use method[open] to open contextmenu, and then use mouse event to set contextmenu's position like this: `
.... methods: { click(e) { const menu = this.$refs.contextmenu.$refs.menu; menu.open(); menu.setPosition(e.pageX, e.pageY, 'right'); } } `
miyoosan commented 3 years ago

I want to open a dynamic context menu programmatic in the right click event handler of a button or component. How can I achieve this?

more possible ways, you can try out the vue-menu instance

liudonghua123 commented 3 years ago

@miyoosan Thanks, I will try your solution. 😄