Reputation: 9617
I am not using webpack, I include vue as external script Something like this:
<script src ="unpckg.com/vue.js-latest"></script>
And I want to use npm module
https://www.npmjs.com/package/vue-context-menu
So I include it like this:
<script src= "https://unpkg.com/[email protected]/vue-context-menu.js"></script>
So how do I use it? Normally I would right:
import contextMenu from 'vue-context-menu'
But it gives me an error now.
Upvotes: 0
Views: 187
Reputation: 20960
It should be simple:
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<script src= "https://unpkg.com/[email protected]/vue-context-menu.js"></script>
<script>
// This is important
Vue.component('own-context-menu', window.VueContextMenu);
</script>
vue-context-menu registers the component on window object as:
window.VueContextMenu = VueContextMenu
Please let me know if it does not help.
Upvotes: 1