Vue-js-modal: how to register this component locally in a component?

Created on 1 Aug 2017  路  6Comments  路  Source: euvl/vue-js-modal

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>

question

All 6 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yyh1102 picture yyh1102  路  3Comments

a3020 picture a3020  路  5Comments

alex3683 picture alex3683  路  4Comments

songoo picture songoo  路  4Comments

Max64 picture Max64  路  4Comments