i got a warning:
[Vue warn]: Failed to mount component: template or render function not defined.
when i use import like this:
import modal from 'vue-js-modal'
and register it in components like this:
components:{
ChatRoom,
Player,
modal
},
and use it like this:
<modal name="test"></modal>
You dont have to do it, plugin does registration for you. There is more to the plugin than just a component.
Just run:
Vue.use(modal)
The problem I have with not being able to register the component locally is that I get this error when running unit tests with karma:
ERROR LOG: '[Vue warn]: Unknown custom element: \
Is there a way to fix that?
@dland512 its not plugin's issue, please use stackoverflow for such matters.
It would be nice to be able to have the option to register locally in addition to via a plugin for those that prefer to avoid plugins. Would you be open to this change?
Agreed, i want to use modals only on certain pages of my spa, so i dont want to register it globally.
@ArkhipovK Nothing stops you from not using modal on some pages and using it on others. The idea of spa itself is that you don't have to use resources to reinitialise same scripts/modules every time you navigate to a new "page" (considering spa is happening on one html page all the time..).
With the current setup, you allocate resource only once.
Overall, avoiding using plugins just sounds wrong to me. You do not save resources and if you do, you still load & execute like 300kb of javascript with vue framework.