Answer the question
In order to leave comments, you need to log in
Is it possible to get the component data from the outside at the right time?
I have a dozen components in the form of tabs. Each tab contains from 5 to 10 selects, inputs, etc. essentially variables.
The "confirm" button is outside and it is when you click it that the data of the current component should be processed.
Bringing more than 50 new variables into the repository with all getters / setters does not raise a hand. I read in the docs that you can use v-model on components, but it's still 10 variables. And the data from the components is needed 1 time, and after switching the tab, it also needs to be cleared.
I came up with two ways, but maybe it's easier?
1. Make the currentActiveModule in the storage and write an array with the data of the active module into it each time the data in it changes. And that means when you press the button, we just take it from there and work.
2. Make not one "confirm" button, but in each module its own, identical. But here serious problems with layout and with the possibility of expansion begin.
Answer the question
In order to leave comments, you need to log in
Parent
Then when we perform some action in the parent, we can refer to the child
<v-component ref="component" />
sendForm() {
const chlidData = this.$refs.component.$data
}
Why do you have a separate component for each tab? They are so different and it is impossible to generalize them to one?
But even in this case, you should have one component for all tabs, which will include different content as a child component by name:
<div class="tab">
<component
v-bind:is="activeTabComponent"
v-model="values"
></component>
</div>
Why do you have a separate component for each tab? They are so different and it is impossible to generalize them to one?
And in this tab component place your button.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question