This Gist describes how to implement context menus in Vue using custom blocks; i.e. without needing to put the context menu explicitly into the template
In making my Vue project, I wanted to be able to create custom context menus (right-click menus)
without putting it into the template. To me, a context menu is relevant to the entire component
and shouldn't actually go into the template. So I wanted to use a custom block to specify a
context menu for the component as a whole. However, there were no libraries available to specify
context menus in a context block; they always needed to be in the template, referenced by the
ref
keyword. This is my attempt at implementing it.
Right now, my code is only suited for a single context menu per component, but it should be fairly easy to refactor to allow multiple context menus per component.
It'd be nice to make this into a full library that other people can npm install
, but for now,
it's simply a proof of concept of the idea.
Now a node module! Check out my repo