dynamically loading routes in vuejs not working
Am working on a project, i want to dynamically load my routes only when its needed instead of loading all the components when the page loads, in route.js here is my code
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
function loadView(view){
return () => import(/* webpackChunkName: "view[request]" */`@/components/${view}.vue`)
}
const router = new Router({
routes: [
{path: '/', name: 'home', component: loadView('Notlogin/HelloWorld')},
{ path: '/add', name: 'add', component: loadView('login/add'), meta:{requireAuth:true}},
{ path: '/add/:id', name: 'addParams', component: loadView('login/add'), alias: '/add', meta:{requireAuth:true}},
{ path: '/dashboard', name: 'dashboard', component: loadView('login/dashboard'), meta:{requireAuth:true}},
{ path: '/profile', name: 'profile', component: loadView('login/profile/index'), meta:{requireAuth:true}},
{ path: '/projectDetails/:id', name: 'projectDetails', component: loadView('login/projectDetails'), meta:{requireAuth:true}},
{ path: '/Projects', name: 'Projects', component: loadView('login/urProjects'), meta:{requireAuth:true}},
{ path: '/projectCat/:id', name: 'projectCat', component: loadView('login/projectCat'), meta:{requireAuth:true}},
{ path: '/Finance', name: 'Finance', component: loadView('login/Finance'), meta:{requireAuth:true}},
{ path: '/login',name: 'login', component: loadView('Notlogin/login')},
{ path: '/forgot',name: 'forgot', component: loadView('Notlogin/forgot')},
{ path: '/register', name: 'register', component: loadView('Notlogin/register')},
{ path: '/test', name: 'test', component: loadView('test')},
{ path: '/404', name: '404', component: loadView('Notlogin/404') },
{ path: '*', redirect: error404}
]
})
export default router
the problem is that i keep getting this error in the console
warning in ./src/components/login/profile/Profile.vue
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other c
ase-semantic.
Use equal casing. Compare these module identifiers:
* C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientnode_modul
esvue-loaderindex.js??ref--0!C:UsersDe Stone of DavidDesktopnode projects
vuejsmyappclientsrccomponentsloginprofileProfile.vue
Used by 1 module(s), i. e.
C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientnode_mod
ulesbabel-loaderlibindex.js!C:UsersDe Stone of DavidDesktopnode projects
vuejsmyappclientnode_modulesvue-loaderlibselector.js?type=script&index=0!C
:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientsrccomponent
sloginprofileprofileDeftails.vue
* C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientnode_modul
esvue-loaderindex.js??ref--0!C:UsersDe Stone of DavidDesktopnode projects
vuejsmyappclientsrccomponentsloginprofileprofile.vue
Used by 1 module(s), i. e.
C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientsrccomp
onents lazy /^./.*.vue$/
pls what am i doing wrong or how can i solve this problem thanks
vue.js vue-component vue-router
add a comment |
Am working on a project, i want to dynamically load my routes only when its needed instead of loading all the components when the page loads, in route.js here is my code
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
function loadView(view){
return () => import(/* webpackChunkName: "view[request]" */`@/components/${view}.vue`)
}
const router = new Router({
routes: [
{path: '/', name: 'home', component: loadView('Notlogin/HelloWorld')},
{ path: '/add', name: 'add', component: loadView('login/add'), meta:{requireAuth:true}},
{ path: '/add/:id', name: 'addParams', component: loadView('login/add'), alias: '/add', meta:{requireAuth:true}},
{ path: '/dashboard', name: 'dashboard', component: loadView('login/dashboard'), meta:{requireAuth:true}},
{ path: '/profile', name: 'profile', component: loadView('login/profile/index'), meta:{requireAuth:true}},
{ path: '/projectDetails/:id', name: 'projectDetails', component: loadView('login/projectDetails'), meta:{requireAuth:true}},
{ path: '/Projects', name: 'Projects', component: loadView('login/urProjects'), meta:{requireAuth:true}},
{ path: '/projectCat/:id', name: 'projectCat', component: loadView('login/projectCat'), meta:{requireAuth:true}},
{ path: '/Finance', name: 'Finance', component: loadView('login/Finance'), meta:{requireAuth:true}},
{ path: '/login',name: 'login', component: loadView('Notlogin/login')},
{ path: '/forgot',name: 'forgot', component: loadView('Notlogin/forgot')},
{ path: '/register', name: 'register', component: loadView('Notlogin/register')},
{ path: '/test', name: 'test', component: loadView('test')},
{ path: '/404', name: '404', component: loadView('Notlogin/404') },
{ path: '*', redirect: error404}
]
})
export default router
the problem is that i keep getting this error in the console
warning in ./src/components/login/profile/Profile.vue
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other c
ase-semantic.
Use equal casing. Compare these module identifiers:
* C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientnode_modul
esvue-loaderindex.js??ref--0!C:UsersDe Stone of DavidDesktopnode projects
vuejsmyappclientsrccomponentsloginprofileProfile.vue
Used by 1 module(s), i. e.
C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientnode_mod
ulesbabel-loaderlibindex.js!C:UsersDe Stone of DavidDesktopnode projects
vuejsmyappclientnode_modulesvue-loaderlibselector.js?type=script&index=0!C
:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientsrccomponent
sloginprofileprofileDeftails.vue
* C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientnode_modul
esvue-loaderindex.js??ref--0!C:UsersDe Stone of DavidDesktopnode projects
vuejsmyappclientsrccomponentsloginprofileprofile.vue
Used by 1 module(s), i. e.
C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientsrccomp
onents lazy /^./.*.vue$/
pls what am i doing wrong or how can i solve this problem thanks
vue.js vue-component vue-router
Might have something to do with your dev environment? forum.vuejs.org/t/…
– Jim B.
Nov 29 '18 at 1:58
This warning occurs when you're importing files with different cases eg: given Files A, B, C in same folder.. in file A: import 'c' , in file B: import 'C' ... In short, i'm not sure this is your root problem..
– Paul Rdt
Nov 29 '18 at 8:15
add a comment |
Am working on a project, i want to dynamically load my routes only when its needed instead of loading all the components when the page loads, in route.js here is my code
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
function loadView(view){
return () => import(/* webpackChunkName: "view[request]" */`@/components/${view}.vue`)
}
const router = new Router({
routes: [
{path: '/', name: 'home', component: loadView('Notlogin/HelloWorld')},
{ path: '/add', name: 'add', component: loadView('login/add'), meta:{requireAuth:true}},
{ path: '/add/:id', name: 'addParams', component: loadView('login/add'), alias: '/add', meta:{requireAuth:true}},
{ path: '/dashboard', name: 'dashboard', component: loadView('login/dashboard'), meta:{requireAuth:true}},
{ path: '/profile', name: 'profile', component: loadView('login/profile/index'), meta:{requireAuth:true}},
{ path: '/projectDetails/:id', name: 'projectDetails', component: loadView('login/projectDetails'), meta:{requireAuth:true}},
{ path: '/Projects', name: 'Projects', component: loadView('login/urProjects'), meta:{requireAuth:true}},
{ path: '/projectCat/:id', name: 'projectCat', component: loadView('login/projectCat'), meta:{requireAuth:true}},
{ path: '/Finance', name: 'Finance', component: loadView('login/Finance'), meta:{requireAuth:true}},
{ path: '/login',name: 'login', component: loadView('Notlogin/login')},
{ path: '/forgot',name: 'forgot', component: loadView('Notlogin/forgot')},
{ path: '/register', name: 'register', component: loadView('Notlogin/register')},
{ path: '/test', name: 'test', component: loadView('test')},
{ path: '/404', name: '404', component: loadView('Notlogin/404') },
{ path: '*', redirect: error404}
]
})
export default router
the problem is that i keep getting this error in the console
warning in ./src/components/login/profile/Profile.vue
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other c
ase-semantic.
Use equal casing. Compare these module identifiers:
* C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientnode_modul
esvue-loaderindex.js??ref--0!C:UsersDe Stone of DavidDesktopnode projects
vuejsmyappclientsrccomponentsloginprofileProfile.vue
Used by 1 module(s), i. e.
C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientnode_mod
ulesbabel-loaderlibindex.js!C:UsersDe Stone of DavidDesktopnode projects
vuejsmyappclientnode_modulesvue-loaderlibselector.js?type=script&index=0!C
:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientsrccomponent
sloginprofileprofileDeftails.vue
* C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientnode_modul
esvue-loaderindex.js??ref--0!C:UsersDe Stone of DavidDesktopnode projects
vuejsmyappclientsrccomponentsloginprofileprofile.vue
Used by 1 module(s), i. e.
C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientsrccomp
onents lazy /^./.*.vue$/
pls what am i doing wrong or how can i solve this problem thanks
vue.js vue-component vue-router
Am working on a project, i want to dynamically load my routes only when its needed instead of loading all the components when the page loads, in route.js here is my code
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
function loadView(view){
return () => import(/* webpackChunkName: "view[request]" */`@/components/${view}.vue`)
}
const router = new Router({
routes: [
{path: '/', name: 'home', component: loadView('Notlogin/HelloWorld')},
{ path: '/add', name: 'add', component: loadView('login/add'), meta:{requireAuth:true}},
{ path: '/add/:id', name: 'addParams', component: loadView('login/add'), alias: '/add', meta:{requireAuth:true}},
{ path: '/dashboard', name: 'dashboard', component: loadView('login/dashboard'), meta:{requireAuth:true}},
{ path: '/profile', name: 'profile', component: loadView('login/profile/index'), meta:{requireAuth:true}},
{ path: '/projectDetails/:id', name: 'projectDetails', component: loadView('login/projectDetails'), meta:{requireAuth:true}},
{ path: '/Projects', name: 'Projects', component: loadView('login/urProjects'), meta:{requireAuth:true}},
{ path: '/projectCat/:id', name: 'projectCat', component: loadView('login/projectCat'), meta:{requireAuth:true}},
{ path: '/Finance', name: 'Finance', component: loadView('login/Finance'), meta:{requireAuth:true}},
{ path: '/login',name: 'login', component: loadView('Notlogin/login')},
{ path: '/forgot',name: 'forgot', component: loadView('Notlogin/forgot')},
{ path: '/register', name: 'register', component: loadView('Notlogin/register')},
{ path: '/test', name: 'test', component: loadView('test')},
{ path: '/404', name: '404', component: loadView('Notlogin/404') },
{ path: '*', redirect: error404}
]
})
export default router
the problem is that i keep getting this error in the console
warning in ./src/components/login/profile/Profile.vue
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other c
ase-semantic.
Use equal casing. Compare these module identifiers:
* C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientnode_modul
esvue-loaderindex.js??ref--0!C:UsersDe Stone of DavidDesktopnode projects
vuejsmyappclientsrccomponentsloginprofileProfile.vue
Used by 1 module(s), i. e.
C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientnode_mod
ulesbabel-loaderlibindex.js!C:UsersDe Stone of DavidDesktopnode projects
vuejsmyappclientnode_modulesvue-loaderlibselector.js?type=script&index=0!C
:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientsrccomponent
sloginprofileprofileDeftails.vue
* C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientnode_modul
esvue-loaderindex.js??ref--0!C:UsersDe Stone of DavidDesktopnode projects
vuejsmyappclientsrccomponentsloginprofileprofile.vue
Used by 1 module(s), i. e.
C:UsersDe Stone of DavidDesktopnode projectsvuejsmyappclientsrccomp
onents lazy /^./.*.vue$/
pls what am i doing wrong or how can i solve this problem thanks
vue.js vue-component vue-router
vue.js vue-component vue-router
asked Nov 28 '18 at 23:10
Js doeeJs doee
175
175
Might have something to do with your dev environment? forum.vuejs.org/t/…
– Jim B.
Nov 29 '18 at 1:58
This warning occurs when you're importing files with different cases eg: given Files A, B, C in same folder.. in file A: import 'c' , in file B: import 'C' ... In short, i'm not sure this is your root problem..
– Paul Rdt
Nov 29 '18 at 8:15
add a comment |
Might have something to do with your dev environment? forum.vuejs.org/t/…
– Jim B.
Nov 29 '18 at 1:58
This warning occurs when you're importing files with different cases eg: given Files A, B, C in same folder.. in file A: import 'c' , in file B: import 'C' ... In short, i'm not sure this is your root problem..
– Paul Rdt
Nov 29 '18 at 8:15
Might have something to do with your dev environment? forum.vuejs.org/t/…
– Jim B.
Nov 29 '18 at 1:58
Might have something to do with your dev environment? forum.vuejs.org/t/…
– Jim B.
Nov 29 '18 at 1:58
This warning occurs when you're importing files with different cases eg: given Files A, B, C in same folder.. in file A: import 'c' , in file B: import 'C' ... In short, i'm not sure this is your root problem..
– Paul Rdt
Nov 29 '18 at 8:15
This warning occurs when you're importing files with different cases eg: given Files A, B, C in same folder.. in file A: import 'c' , in file B: import 'C' ... In short, i'm not sure this is your root problem..
– Paul Rdt
Nov 29 '18 at 8:15
add a comment |
0
active
oldest
votes
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%2f53529505%2fdynamically-loading-routes-in-vuejs-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f53529505%2fdynamically-loading-routes-in-vuejs-not-working%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
Might have something to do with your dev environment? forum.vuejs.org/t/…
– Jim B.
Nov 29 '18 at 1:58
This warning occurs when you're importing files with different cases eg: given Files A, B, C in same folder.. in file A: import 'c' , in file B: import 'C' ... In short, i'm not sure this is your root problem..
– Paul Rdt
Nov 29 '18 at 8:15