M
M
Marat Shornikov2019-05-21 22:53:36
Vue.js
Marat Shornikov, 2019-05-21 22:53:36

VUE v-for outside or inside component?

Hello.
There is a complex list, with many html elements and js events at the line level.
what should be a vue component - a description of a single line of the list or the entire list.
After all, the component is reusable data, and this indicates that the component is a string.
However, in the examples found on the net, the whole list is taken out into the component.
It seems to me that creating a component from a string, leaving v-for in the "parent" code is more correct - readability will increase. But perhaps something else will suffer? ..
What is the right way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Kulakov, 2019-05-22
@shornikov

If you think that the list string is a rather complicated element, then take it out into a separate component. It is obvious that he is quite self-sufficient. And the main thing here, as correctly noted above, is encapsulation or the fight against complexity. Separately, the row component will be easier to maintain and test if necessary.

N
NewDevLab, 2019-05-21
@NewDevLab

in one component.
Reusable, yes. But where else will this string component be used...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question