Problems with building components in vue

ask Daniel, I now have three pages with roughly the same layout, only a few components or different text, how to build components is better, now think of two kinds:

  1. write a Common component. All three pages introduce Common, pass values through different props, and control the layout
  2. write a parent component Common, and the other three pages extends, the parent component, to control the behavior in data,methods.

which is better, or how do the gods achieve it?

Jul.15,2022

only slot slots can be used to distribute content where the text is different, or the props can be defined by the child component. The parameter is passed by the parent component
component reference is different, and you can use is to switch different components
example: < component Vacable answer is = "currentTabComponent" > < / component >


the layout of the page is roughly the same, except for a few components or different text

according to your description, this is a page-level component, so you should write a component that consists of the same parts of three pages, and then use slot (slots) to form different pages.

Menu