question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Child Component not getting registered on a global component?

See original GitHub issue

i dont know if i am missing something… but the following code is not working

let nav = Vue.extend({
            template: require('../templates/nav/nav.html'),
            components: {
                'item': { 
                      name:'item',
                      template: require('../templates/nav/item.html') 
                 }
            }
        });

Vue.component('nav', nav);
<nav>
    <item></item>
</nav>

it says…

app.js:1112 [Vue warn]: Unknown custom element: <item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

Vue v1.0.25

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
simplesmilercommented, Jun 28, 2016

@Milewski you can try to use inline-template, but this won’t let you specify templates for the components, and will prohibit the use of slots.

1reaction
milewskicommented, Jun 28, 2016

so it means externally if i am outside of the template i cant invoke the child… it would need to be a global component for that and access the parent with this.$parent ?

for example this workflow would be impossible right?

<parent>
    <child></child>
</parent>

<another-parent>
     <child></child>
</another-parent>

in this example the <child> must to be a global component… and the two child will be exactly the same not mattering who is the parent? if i want to differentiate them then i would go like this

<parent>
    <child-one></child-one>
</parent>

<another-parent>
     <child-two></child-two>
</another-parent>

so in this case i will have 4 global components… this is the only way? there is no way to shirnk it down to 2 global components <parent> and <another-parent> and have the <child> element as a child within the same name?

<component>
    <child></child>
</component>

outputting..

<div class="im-component">
    <button>im child</button>
</div>

and

<another-component>
    <child></child>
</another-component>

outputting..

<div class="im-another-component">
    <div>
        <input>
    </div>
</div>

note: i am using the same name <child> on both places

Read more comments on GitHub >

github_iconTop Results From Across the Web

Child components not updating global state - Stack Overflow
1 Answer 1 · On the NumOfTitles.js file you are setting the field "materialType" instead of the "numOfTitles" field. · On the SubjOfInterest.js ......
Read more >
Component Registration - Vue.js
Global registration makes dependency relationships less explicit in large applications. It makes it difficult to locate a child component's implementation from ...
Read more >
Component interaction - Angular
The parent-child relationship of the components is not established within each component's respective class with the local variable technique. Because the class ...
Read more >
Registering child components with parent : r/reactjs - Reddit
If I wait until after the component is mounted to register that, I might get a flicker as the data in the parent...
Read more >
Parent/Child Component Communication in Vue
Although it is not a very convincing reason, the convention to stick to events for communication between child components and their parent ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found