Answer the question
In order to leave comments, you need to log in
How to correctly structure components in a Vue project?
In the Vue documentation, with regards to word order in components, recommendations are made to go from the more general.
That is, I have, for example, a User page, on which there are several sections, About, Content, Posts.
And in the end, the components come out like this:
User
-- UserSectionAbout.vue
-- UserSectionContent.vue
-- UserSectionPosts.vue
User
-- UserSectionAbout.vue
-- UserSectionContent.vue
-- UserSectionHeader.vue
-- UserSectionPosts.vue
Answer the question
In order to leave comments, you need to log in
components/
User/
Header.vue
Section/
About.vue
Content.vue
Posts.vue
name: "UserHeader",
name: "UserSectionAbout",
name: "UserSectionContent",
name: "UserSectionPosts",
According to your logic, it should be like this:
-- UserHeader.vue
-- UserSectionAbout.vue
-- UserSectionContent.vue
-- UserSectionPosts.vue
Alternatively, you can sort everything into folders:
/User
Header.vue
/Sections
Section1.vue
Section2.vue
I would split like this:
/Components/
/Components/Users/
/Components/Users/About.vue
/Components/Users/Content.vue
/Components/Users/Header.vue
/Components/Users/Posts.vue
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question