A
A
Andrey Sharapov2019-08-14 10:31:52
Vue.js
Andrey Sharapov, 2019-08-14 10:31:52

Is it right to make components large?

I study vue and periodically review the code of sites in which almost the entire page (static) consists of components, for example:

<site-navigation></ ... >
<site-masthead></ ... >
<site-content></ ... >
<site-bars></ ... >
<site-footer>

other.

But at the same time, the page itself looks large, with a bunch of text and pictures. Hence the question: is it appropriate to use components like this? I use them to embed some .card elements, sliders and other small blocks. But is it right to put a whole table of 50+ positions into the component, blog posts or create a modal through the component, in which to display a huge list of the price type? All text, as I understand it, is in the js file. Or is it better to write plain html/pug and not bother with volume?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
coderisimo, 2019-08-14
@Madeas

The idea is that you are writing a table component. He doesn't care how many lines there are. It receives a certain array of objects and, in accordance with this data, creates a table on the page. The table can have 5 rows, or maybe 500. That's the profit of the components. You have created a table component that accepts a specific data format and now you can insert it in different places on the site, feed it different data sets. And every time everything will work as it should.
And if changes are needed, you just change the component itself and wherever it is used, in all 10 places on the site, your component will be modified automatically.

O
Olga Veter, 2019-08-14
@vetero4eg

Look at some book, master class or course on vue, thoroughly, in order. One thing is better, but from and to. You have a systemic misunderstanding of the approach; it is not normal to solve this with point questions.

A
Anton Anton, 2019-08-14
@Fragster

There most likely a hierarchical structure of components.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question