B
B
BonBon Slick2020-01-08 00:16:56
Vue.js
BonBon Slick, 2020-01-08 00:16:56

How to organize the structure of components when the methods are almost the same but the HTML markup is different?

2 different pages, one with categories, the other with posts.
Both have common motods, the word loadMore() when scrolling, notification when there are no results, and others. But there are different naturally.
However, the markup is different. on the post page, we display the post + description + title, and on the category page, the title + image.
On masonry posts, but in grid categories.
It will be expensive to duplicate the method, there are about 150 lines and 8 methods for lazy loading.
How would you break down the structure of the application, components?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Aetae, 2020-01-08
@BonBonSlick

That's what mixins are for.

D
Dmitry Belyaev, 2020-01-08
@bingo347

Take out the general logic in vuex and do not fence bicycles.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question