What is the difference between the views and components folders in a Vue project?2019 Community Moderator ElectionShared variables between JS and SCSS in VueWhat is the difference between importing Vue.js library and installing it via Vue-CLI?Laravel & Vue: Communication between different Vue components split by Laravel viewsVue 'export default' vs 'new Vue'How to direct vue-cli to put built project files in different directories?Writing a vue component templatesStarting the dev server in project generated by vue cli 3How can I change main folders in VUEvue-cli build a lib from component and import it
Tikz: place node leftmost of two nodes of different widths
I got the following comment from a reputed math journal. What does it mean?
Calculate the frequency of characters in a string
Is it insecure to send a password in a `curl` command?
What if (if any) the reason to buy in small local stores?
Differential and Linear trail propagation in Noekeon
Unfrosted light bulb
Why Choose Less Effective Armour Types?
Turning a hard to access nut?
Fewest number of steps to reach 200 using special calculator
Variable completely messes up echoed string
How to generate binary array whose elements with values 1 are randomly drawn
How can I wire 7 outdoor posts correctly?
Is it correct to say "which country do you like the most?"
I seem to dance, I am not a dancer. Who am I?
Light propagating through a sound wave
In the 1924 version of The Thief of Bagdad, no character is named, right?
HP P840 HDD RAID 5 many strange drive failures
Can you move over difficult terrain with only 5 feet of movement?
Is this an example of a Neapolitan chord?
How could an airship be repaired midflight?
Probably overheated black color SMD pads
Generic TVP tradeoffs?
Suggestions on how to spend Shaabath (constructively) alone
What is the difference between the views and components folders in a Vue project?
2019 Community Moderator ElectionShared variables between JS and SCSS in VueWhat is the difference between importing Vue.js library and installing it via Vue-CLI?Laravel & Vue: Communication between different Vue components split by Laravel viewsVue 'export default' vs 'new Vue'How to direct vue-cli to put built project files in different directories?Writing a vue component templatesStarting the dev server in project generated by vue cli 3How can I change main folders in VUEvue-cli build a lib from component and import it
I just used the command line (CLI) to initialize a Vue.js project. The CLI created a src/components and src/views folder.
It has been a few months since I have worked with a Vue project and the folder structure seems new to me.
What is the difference between the views and components folders in a Vue project generated with vue-cli?
vue.js vuejs2 vue-cli vue-cli-3
add a comment |
I just used the command line (CLI) to initialize a Vue.js project. The CLI created a src/components and src/views folder.
It has been a few months since I have worked with a Vue project and the folder structure seems new to me.
What is the difference between the views and components folders in a Vue project generated with vue-cli?
vue.js vuejs2 vue-cli vue-cli-3
2
I don't think they are different in the sense that they are both single-file view components. But your page views (Home.vue, About.vue, Checkout.vue) can be kept separate from your components (Button.vue, LoadingSpinner.vue, etc)
– Jeff
Jun 14 '18 at 21:00
This shines some light on the differences in structure: blog.pusher.com/new-vue-cli-simplifies-development
– connexo
Jun 14 '18 at 21:05
1
@Jeff are you a politician, if not you should be. You just repeated the Ops question, but managed to make it look like an answer. LOL.
– PrestonDocks
Aug 23 '18 at 9:50
add a comment |
I just used the command line (CLI) to initialize a Vue.js project. The CLI created a src/components and src/views folder.
It has been a few months since I have worked with a Vue project and the folder structure seems new to me.
What is the difference between the views and components folders in a Vue project generated with vue-cli?
vue.js vuejs2 vue-cli vue-cli-3
I just used the command line (CLI) to initialize a Vue.js project. The CLI created a src/components and src/views folder.
It has been a few months since I have worked with a Vue project and the folder structure seems new to me.
What is the difference between the views and components folders in a Vue project generated with vue-cli?
vue.js vuejs2 vue-cli vue-cli-3
vue.js vuejs2 vue-cli vue-cli-3
edited Aug 16 '18 at 22:24
Ricky
10.5k12335
10.5k12335
asked Jun 14 '18 at 20:57
drsnarkdrsnark
448613
448613
2
I don't think they are different in the sense that they are both single-file view components. But your page views (Home.vue, About.vue, Checkout.vue) can be kept separate from your components (Button.vue, LoadingSpinner.vue, etc)
– Jeff
Jun 14 '18 at 21:00
This shines some light on the differences in structure: blog.pusher.com/new-vue-cli-simplifies-development
– connexo
Jun 14 '18 at 21:05
1
@Jeff are you a politician, if not you should be. You just repeated the Ops question, but managed to make it look like an answer. LOL.
– PrestonDocks
Aug 23 '18 at 9:50
add a comment |
2
I don't think they are different in the sense that they are both single-file view components. But your page views (Home.vue, About.vue, Checkout.vue) can be kept separate from your components (Button.vue, LoadingSpinner.vue, etc)
– Jeff
Jun 14 '18 at 21:00
This shines some light on the differences in structure: blog.pusher.com/new-vue-cli-simplifies-development
– connexo
Jun 14 '18 at 21:05
1
@Jeff are you a politician, if not you should be. You just repeated the Ops question, but managed to make it look like an answer. LOL.
– PrestonDocks
Aug 23 '18 at 9:50
2
2
I don't think they are different in the sense that they are both single-file view components. But your page views (Home.vue, About.vue, Checkout.vue) can be kept separate from your components (Button.vue, LoadingSpinner.vue, etc)
– Jeff
Jun 14 '18 at 21:00
I don't think they are different in the sense that they are both single-file view components. But your page views (Home.vue, About.vue, Checkout.vue) can be kept separate from your components (Button.vue, LoadingSpinner.vue, etc)
– Jeff
Jun 14 '18 at 21:00
This shines some light on the differences in structure: blog.pusher.com/new-vue-cli-simplifies-development
– connexo
Jun 14 '18 at 21:05
This shines some light on the differences in structure: blog.pusher.com/new-vue-cli-simplifies-development
– connexo
Jun 14 '18 at 21:05
1
1
@Jeff are you a politician, if not you should be. You just repeated the Ops question, but managed to make it look like an answer. LOL.
– PrestonDocks
Aug 23 '18 at 9:50
@Jeff are you a politician, if not you should be. You just repeated the Ops question, but managed to make it look like an answer. LOL.
– PrestonDocks
Aug 23 '18 at 9:50
add a comment |
2 Answers
2
active
oldest
votes
First of all, both folders, src/components and src/views, contain Vue components.
The key difference is that some Vue components act as Views for routing.
When dealing with routing in Vue, usually with Vue Router, routes are defined in order to switch the current view used in the <router-view> component. These routes are typically located at src/router/routes.js, where we can see something like this:
import Home from '@/views/Home.vue'
import About from '@/views/About.vue'
export default [
path: '/',
name: 'home',
component: Home,
,
path: '/about',
name: 'about',
component: About,
,
]
The components located under src/components are less likely to be used in a route whereas components located under src/views will be used by at least one route.
Vue CLI aims to be the standard tooling baseline for the Vue
ecosystem. It ensures the various build tools work smoothly together
with sensible defaults so you can focus on writing your app instead of
spending days wrangling with configurations. At the same time, it
still offers the flexibility to tweak the config of each tool without
the need for ejecting.
Vue CLI aims for rapid Vue.js development, it keeps things simple and offers flexibility. Its goal is to enable teams of varying skill levels to set up a new project and get started.
At the end of the day, it is a matter of convenience and application structure.
- Some people like to have their Views folder under
src/routerlike
this enterprise boilerplate. - Some people call it Pages instead of Views.
- Some people have all their components under the same folder.
Choose the application structure that best suits the project you are working on.
Bonus: Dan Abramov recommends this file structure for React and Vue projects.
4
This is 100% right. You can structure your app any way that makes sense to you. I personally use "src/pages" for all routes. In that folder, I will create sub-folder for each "area" of the site. Example "src/pages/questions" and in that folder, I will have an index.vue which will have the list of questions. I will have an add.vue that will be the page for adding questions, etc. These "pages" typically simply assemble the needed components to make up the "page". In my "src/components" folder I will create subfolders for things like navigation, form elements, custom shared components, etc...
– TimWickstrom.com
Jun 14 '18 at 21:38
add a comment |
I think its more of a convention. Something that is reusable can be kept in src/components folder something that is tied to router can be kept in src/views
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50865828%2fwhat-is-the-difference-between-the-views-and-components-folders-in-a-vue-project%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
First of all, both folders, src/components and src/views, contain Vue components.
The key difference is that some Vue components act as Views for routing.
When dealing with routing in Vue, usually with Vue Router, routes are defined in order to switch the current view used in the <router-view> component. These routes are typically located at src/router/routes.js, where we can see something like this:
import Home from '@/views/Home.vue'
import About from '@/views/About.vue'
export default [
path: '/',
name: 'home',
component: Home,
,
path: '/about',
name: 'about',
component: About,
,
]
The components located under src/components are less likely to be used in a route whereas components located under src/views will be used by at least one route.
Vue CLI aims to be the standard tooling baseline for the Vue
ecosystem. It ensures the various build tools work smoothly together
with sensible defaults so you can focus on writing your app instead of
spending days wrangling with configurations. At the same time, it
still offers the flexibility to tweak the config of each tool without
the need for ejecting.
Vue CLI aims for rapid Vue.js development, it keeps things simple and offers flexibility. Its goal is to enable teams of varying skill levels to set up a new project and get started.
At the end of the day, it is a matter of convenience and application structure.
- Some people like to have their Views folder under
src/routerlike
this enterprise boilerplate. - Some people call it Pages instead of Views.
- Some people have all their components under the same folder.
Choose the application structure that best suits the project you are working on.
Bonus: Dan Abramov recommends this file structure for React and Vue projects.
4
This is 100% right. You can structure your app any way that makes sense to you. I personally use "src/pages" for all routes. In that folder, I will create sub-folder for each "area" of the site. Example "src/pages/questions" and in that folder, I will have an index.vue which will have the list of questions. I will have an add.vue that will be the page for adding questions, etc. These "pages" typically simply assemble the needed components to make up the "page". In my "src/components" folder I will create subfolders for things like navigation, form elements, custom shared components, etc...
– TimWickstrom.com
Jun 14 '18 at 21:38
add a comment |
First of all, both folders, src/components and src/views, contain Vue components.
The key difference is that some Vue components act as Views for routing.
When dealing with routing in Vue, usually with Vue Router, routes are defined in order to switch the current view used in the <router-view> component. These routes are typically located at src/router/routes.js, where we can see something like this:
import Home from '@/views/Home.vue'
import About from '@/views/About.vue'
export default [
path: '/',
name: 'home',
component: Home,
,
path: '/about',
name: 'about',
component: About,
,
]
The components located under src/components are less likely to be used in a route whereas components located under src/views will be used by at least one route.
Vue CLI aims to be the standard tooling baseline for the Vue
ecosystem. It ensures the various build tools work smoothly together
with sensible defaults so you can focus on writing your app instead of
spending days wrangling with configurations. At the same time, it
still offers the flexibility to tweak the config of each tool without
the need for ejecting.
Vue CLI aims for rapid Vue.js development, it keeps things simple and offers flexibility. Its goal is to enable teams of varying skill levels to set up a new project and get started.
At the end of the day, it is a matter of convenience and application structure.
- Some people like to have their Views folder under
src/routerlike
this enterprise boilerplate. - Some people call it Pages instead of Views.
- Some people have all their components under the same folder.
Choose the application structure that best suits the project you are working on.
Bonus: Dan Abramov recommends this file structure for React and Vue projects.
4
This is 100% right. You can structure your app any way that makes sense to you. I personally use "src/pages" for all routes. In that folder, I will create sub-folder for each "area" of the site. Example "src/pages/questions" and in that folder, I will have an index.vue which will have the list of questions. I will have an add.vue that will be the page for adding questions, etc. These "pages" typically simply assemble the needed components to make up the "page". In my "src/components" folder I will create subfolders for things like navigation, form elements, custom shared components, etc...
– TimWickstrom.com
Jun 14 '18 at 21:38
add a comment |
First of all, both folders, src/components and src/views, contain Vue components.
The key difference is that some Vue components act as Views for routing.
When dealing with routing in Vue, usually with Vue Router, routes are defined in order to switch the current view used in the <router-view> component. These routes are typically located at src/router/routes.js, where we can see something like this:
import Home from '@/views/Home.vue'
import About from '@/views/About.vue'
export default [
path: '/',
name: 'home',
component: Home,
,
path: '/about',
name: 'about',
component: About,
,
]
The components located under src/components are less likely to be used in a route whereas components located under src/views will be used by at least one route.
Vue CLI aims to be the standard tooling baseline for the Vue
ecosystem. It ensures the various build tools work smoothly together
with sensible defaults so you can focus on writing your app instead of
spending days wrangling with configurations. At the same time, it
still offers the flexibility to tweak the config of each tool without
the need for ejecting.
Vue CLI aims for rapid Vue.js development, it keeps things simple and offers flexibility. Its goal is to enable teams of varying skill levels to set up a new project and get started.
At the end of the day, it is a matter of convenience and application structure.
- Some people like to have their Views folder under
src/routerlike
this enterprise boilerplate. - Some people call it Pages instead of Views.
- Some people have all their components under the same folder.
Choose the application structure that best suits the project you are working on.
Bonus: Dan Abramov recommends this file structure for React and Vue projects.
First of all, both folders, src/components and src/views, contain Vue components.
The key difference is that some Vue components act as Views for routing.
When dealing with routing in Vue, usually with Vue Router, routes are defined in order to switch the current view used in the <router-view> component. These routes are typically located at src/router/routes.js, where we can see something like this:
import Home from '@/views/Home.vue'
import About from '@/views/About.vue'
export default [
path: '/',
name: 'home',
component: Home,
,
path: '/about',
name: 'about',
component: About,
,
]
The components located under src/components are less likely to be used in a route whereas components located under src/views will be used by at least one route.
Vue CLI aims to be the standard tooling baseline for the Vue
ecosystem. It ensures the various build tools work smoothly together
with sensible defaults so you can focus on writing your app instead of
spending days wrangling with configurations. At the same time, it
still offers the flexibility to tweak the config of each tool without
the need for ejecting.
Vue CLI aims for rapid Vue.js development, it keeps things simple and offers flexibility. Its goal is to enable teams of varying skill levels to set up a new project and get started.
At the end of the day, it is a matter of convenience and application structure.
- Some people like to have their Views folder under
src/routerlike
this enterprise boilerplate. - Some people call it Pages instead of Views.
- Some people have all their components under the same folder.
Choose the application structure that best suits the project you are working on.
Bonus: Dan Abramov recommends this file structure for React and Vue projects.
edited Oct 3 '18 at 2:33
answered Jun 14 '18 at 21:24
RickyRicky
10.5k12335
10.5k12335
4
This is 100% right. You can structure your app any way that makes sense to you. I personally use "src/pages" for all routes. In that folder, I will create sub-folder for each "area" of the site. Example "src/pages/questions" and in that folder, I will have an index.vue which will have the list of questions. I will have an add.vue that will be the page for adding questions, etc. These "pages" typically simply assemble the needed components to make up the "page". In my "src/components" folder I will create subfolders for things like navigation, form elements, custom shared components, etc...
– TimWickstrom.com
Jun 14 '18 at 21:38
add a comment |
4
This is 100% right. You can structure your app any way that makes sense to you. I personally use "src/pages" for all routes. In that folder, I will create sub-folder for each "area" of the site. Example "src/pages/questions" and in that folder, I will have an index.vue which will have the list of questions. I will have an add.vue that will be the page for adding questions, etc. These "pages" typically simply assemble the needed components to make up the "page". In my "src/components" folder I will create subfolders for things like navigation, form elements, custom shared components, etc...
– TimWickstrom.com
Jun 14 '18 at 21:38
4
4
This is 100% right. You can structure your app any way that makes sense to you. I personally use "src/pages" for all routes. In that folder, I will create sub-folder for each "area" of the site. Example "src/pages/questions" and in that folder, I will have an index.vue which will have the list of questions. I will have an add.vue that will be the page for adding questions, etc. These "pages" typically simply assemble the needed components to make up the "page". In my "src/components" folder I will create subfolders for things like navigation, form elements, custom shared components, etc...
– TimWickstrom.com
Jun 14 '18 at 21:38
This is 100% right. You can structure your app any way that makes sense to you. I personally use "src/pages" for all routes. In that folder, I will create sub-folder for each "area" of the site. Example "src/pages/questions" and in that folder, I will have an index.vue which will have the list of questions. I will have an add.vue that will be the page for adding questions, etc. These "pages" typically simply assemble the needed components to make up the "page". In my "src/components" folder I will create subfolders for things like navigation, form elements, custom shared components, etc...
– TimWickstrom.com
Jun 14 '18 at 21:38
add a comment |
I think its more of a convention. Something that is reusable can be kept in src/components folder something that is tied to router can be kept in src/views
add a comment |
I think its more of a convention. Something that is reusable can be kept in src/components folder something that is tied to router can be kept in src/views
add a comment |
I think its more of a convention. Something that is reusable can be kept in src/components folder something that is tied to router can be kept in src/views
I think its more of a convention. Something that is reusable can be kept in src/components folder something that is tied to router can be kept in src/views
answered Mar 6 at 21:48
RaviRavi
81331021
81331021
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50865828%2fwhat-is-the-difference-between-the-views-and-components-folders-in-a-vue-project%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
I don't think they are different in the sense that they are both single-file view components. But your page views (Home.vue, About.vue, Checkout.vue) can be kept separate from your components (Button.vue, LoadingSpinner.vue, etc)
– Jeff
Jun 14 '18 at 21:00
This shines some light on the differences in structure: blog.pusher.com/new-vue-cli-simplifies-development
– connexo
Jun 14 '18 at 21:05
1
@Jeff are you a politician, if not you should be. You just repeated the Ops question, but managed to make it look like an answer. LOL.
– PrestonDocks
Aug 23 '18 at 9:50