I am trying to set up a reference from one locally defined vue2 Component to another like so:
new Vue({
el: '#app',
components: {
'foo': {template: '<p>Foo</p>'},
'bar': {template: '<foo />'}
}
});
When trying to render <foo>
(see this jsfiddle), Vue (Vue 2.2.1) emits a warning that:
[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.
I have tried to include the name
option for component foo
, as suggested by the warning and the section on recursive components in the guide, but this makes no difference.
Everything works fine if I register the components globally (jsfiddle):
Vue.component('foo', {template: '<p>Foo</p>'});
Vue.component('bar', {template: '<foo />'});
new Vue({
el: '#app'
});
Is there a simple way to make the local definitions work, or should I just proceed with globally defined components?