Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize component Development in Vue

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to achieve component-based development in Vue". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1, rewritten as two components of level 1 option and level 2 option respectively (it seems to compare low)

2. Refer to the 4-level linkage component and rewrite it into optional level 1 option or level 2 option (it's a bit of a hassle, I'll have to check that the address hasn't been broken by me)

3, rewrite a universal unlimited linkage menu (convenient and optional)

In the end, I chose 3 and made a new one myself.

As for why there is no integration 2, it is mainly because there are some differences in the different logic of the business pages on which the two components are located:

1 the logic of getting the list may be different, whether to get level 4 at once or only level 1 or level 2 at a time

If this is uncertain, it will have to be dealt with when it is made into a general-purpose component.

2 I play the option directly, and the address is to jump to the new page and then click the option.

I can transfer data by parent-child components, and the address uses vuex (non-parent-son).

In short, the cost of implementation and maintenance is high, and the value of reuse is not so high.

This means that each of the two pages has a component with the same style and different logic.

This is completely 2 components.

Copy their common style parts and implement their business logic within each.

The two components are placed in different plates, independent of each other, and are easy to manage and maintain.

At this time, combined with the vue component diagram, you will be clear.

For component-based development

Divide and conquer (own business logic) is more important than reuse (the same logic)!

Complex business logic combined with vuex is more convenient to realize componentization.

So I understand that componentized components should generally refer to high cohesion and low coupling (a professional term given to me by a certain phper, I don't know if it's right to use it).

This is the end of the content of "how to achieve component-based development in Vue". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report