T
T
thorii2017-08-23 19:40:21
JavaScript
thorii, 2017-08-23 19:40:21

What is the correct way to concatenate data for multiple vue.js components?

Let's say the application looks like this

<div id="app">
    <app-view-port />
</div>

appViewPort Template
<div class="view">
    <post-form />
    <post-list />
</div>

postList takes the data from the local data{ posts: [] } and builds the list with -v-for.
How to push to postList data{ posts: [] } from postForm?
I tried to transfer data to the root component, but the descendants do not see it

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2017-08-23
@thorii

And how did you show data to descendants? Pass it through props to each of them.

<div class="view">
    <post-form :posts="posts" />
    <post-list :posts="posts" />
</div>

In each of the components, do not forget to specify the property
props: ['posts']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question