K
K
kiranananda2018-10-21 18:45:37
Vue.js
kiranananda, 2018-10-21 18:45:37

Correct relationship between components?

Hello!
I have a root component, for example print-form. In this component, a component for rendering tabs is nested, then a component for rendering a list of fields in one tab is nested, then a component that combines different types of data input (input). And finally, wrappers over inputs. In the parent component, I pass an array of tabs and field descriptions through props. And then in each component a piece of this array is passed to the child.
But now the task is to send the form via Ajax . That is, I need to get all the value values ​​\u200b\u200bin one array and send it already. So what is the right way to implement a structure of this level of nesting and be able to get the value values ​​of the final elements?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aleksey Solovyev, 2018-10-21
@kiranananda

It is convenient to use store. Vue has Vuex
Store data in store: Then you can access this data from any component:

import { mapGetters } from 'vuex';

// code...
computed: {
  ...mapGetters({
    data: 'getData', 
  }),
},

The data is reactive.
ps there is a convenient way to split into modules (user, global etc)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question