Vue component parent from child recursive include
up vote
0
down vote
favorite
So I want to have many components nested to each other and included dynamically.
Lets assume simple case:
-container
-row
-container
-row
-widget
etc.
So how can I include container that will load row which will load previous component container in an elegant way (recursive I guess)
I want this functionality for more components than just container
and row
javascript vuejs2 components
add a comment |
up vote
0
down vote
favorite
So I want to have many components nested to each other and included dynamically.
Lets assume simple case:
-container
-row
-container
-row
-widget
etc.
So how can I include container that will load row which will load previous component container in an elegant way (recursive I guess)
I want this functionality for more components than just container
and row
javascript vuejs2 components
I want to bubble down withdata
as I am including tree based json.
– Trouble
Nov 7 at 16:57
this could be useful alligator.io/vuejs/recursive-components
– eldo
Nov 7 at 21:20
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
So I want to have many components nested to each other and included dynamically.
Lets assume simple case:
-container
-row
-container
-row
-widget
etc.
So how can I include container that will load row which will load previous component container in an elegant way (recursive I guess)
I want this functionality for more components than just container
and row
javascript vuejs2 components
So I want to have many components nested to each other and included dynamically.
Lets assume simple case:
-container
-row
-container
-row
-widget
etc.
So how can I include container that will load row which will load previous component container in an elegant way (recursive I guess)
I want this functionality for more components than just container
and row
javascript vuejs2 components
javascript vuejs2 components
asked Nov 7 at 16:07
Trouble
15115
15115
I want to bubble down withdata
as I am including tree based json.
– Trouble
Nov 7 at 16:57
this could be useful alligator.io/vuejs/recursive-components
– eldo
Nov 7 at 21:20
add a comment |
I want to bubble down withdata
as I am including tree based json.
– Trouble
Nov 7 at 16:57
this could be useful alligator.io/vuejs/recursive-components
– eldo
Nov 7 at 21:20
I want to bubble down with
data
as I am including tree based json.– Trouble
Nov 7 at 16:57
I want to bubble down with
data
as I am including tree based json.– Trouble
Nov 7 at 16:57
this could be useful alligator.io/vuejs/recursive-components
– eldo
Nov 7 at 21:20
this could be useful alligator.io/vuejs/recursive-components
– eldo
Nov 7 at 21:20
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
So to achieve my goal I have to build ComponentLoader and child components loaded from it.
ComponentLoader.vue
<template
v-for="(block, index) in data.children">
<component
v-if="component"
:is="component"
:key="`container-${block.id}-${index}`"
:data="block"/>
</template>
</template>
Which for instance will load Article component from its children:
ArticleComponent.vue
<template>
<SimpleArticle
:data="data"/>
<ComponentLoader
v-if="data.children"
:data="data"/>
</template>
So ArticleComponent
will call ComponentLoader
again if it has more children to load. This way works for me and is recursively going through the data tree.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
So to achieve my goal I have to build ComponentLoader and child components loaded from it.
ComponentLoader.vue
<template
v-for="(block, index) in data.children">
<component
v-if="component"
:is="component"
:key="`container-${block.id}-${index}`"
:data="block"/>
</template>
</template>
Which for instance will load Article component from its children:
ArticleComponent.vue
<template>
<SimpleArticle
:data="data"/>
<ComponentLoader
v-if="data.children"
:data="data"/>
</template>
So ArticleComponent
will call ComponentLoader
again if it has more children to load. This way works for me and is recursively going through the data tree.
add a comment |
up vote
0
down vote
So to achieve my goal I have to build ComponentLoader and child components loaded from it.
ComponentLoader.vue
<template
v-for="(block, index) in data.children">
<component
v-if="component"
:is="component"
:key="`container-${block.id}-${index}`"
:data="block"/>
</template>
</template>
Which for instance will load Article component from its children:
ArticleComponent.vue
<template>
<SimpleArticle
:data="data"/>
<ComponentLoader
v-if="data.children"
:data="data"/>
</template>
So ArticleComponent
will call ComponentLoader
again if it has more children to load. This way works for me and is recursively going through the data tree.
add a comment |
up vote
0
down vote
up vote
0
down vote
So to achieve my goal I have to build ComponentLoader and child components loaded from it.
ComponentLoader.vue
<template
v-for="(block, index) in data.children">
<component
v-if="component"
:is="component"
:key="`container-${block.id}-${index}`"
:data="block"/>
</template>
</template>
Which for instance will load Article component from its children:
ArticleComponent.vue
<template>
<SimpleArticle
:data="data"/>
<ComponentLoader
v-if="data.children"
:data="data"/>
</template>
So ArticleComponent
will call ComponentLoader
again if it has more children to load. This way works for me and is recursively going through the data tree.
So to achieve my goal I have to build ComponentLoader and child components loaded from it.
ComponentLoader.vue
<template
v-for="(block, index) in data.children">
<component
v-if="component"
:is="component"
:key="`container-${block.id}-${index}`"
:data="block"/>
</template>
</template>
Which for instance will load Article component from its children:
ArticleComponent.vue
<template>
<SimpleArticle
:data="data"/>
<ComponentLoader
v-if="data.children"
:data="data"/>
</template>
So ArticleComponent
will call ComponentLoader
again if it has more children to load. This way works for me and is recursively going through the data tree.
answered Nov 10 at 16:21
Trouble
15115
15115
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53193340%2fvue-component-parent-from-child-recursive-include%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
I want to bubble down with
data
as I am including tree based json.– Trouble
Nov 7 at 16:57
this could be useful alligator.io/vuejs/recursive-components
– eldo
Nov 7 at 21:20