VUE.js Routing Configuration
I am creating an application where I have a list of users, when I click on a single user, it takes me to that specific users profile. I am using ASP.NET Core API with Vue.js as my front end. My API is working so when I click on the user, I am able to see the data coming from my database using Chrome dev Tools and Postman. However, once my page redirects to their profile, that page is blank. When I look in dev tools, I can see that its hitting my API and getting the correct information when looking at the preview tab.
So my question is, why is my page blank and not providing me with that users information. Can someone help me look at my routing, I think that is where my issue is?
I am passing their lastName as the param, but eventually I will pass a unique id

Here is my Profile.vue page, this is where I should see the users profile
<template>
<div class="container">
<v-card>
<v-data-table :headers="headers"
:items="records"
:search="search">
<template slot="items" slot-scope="records">
<td class="text-xl-left"> records.item.firstName </td>
<td class="text-xs-left"> records.item.email </td>
<td class="text-xs-left"> records.item.phone </td>
<td class="text-xs-left"> records.item.city </td>
<td class="justify-center layout px-0"></td>
</template>
</v-data-table>
</v-card>
</div>
</template>
<script>
import api from '../store/api.js'
export default
data()
return
records: ,
headers: [
text: 'Full Name', value: 'fullName' ,
text: 'Email', value: 'email' ,
text: 'Phone', value: 'phone' ,
text: 'City', value: 'city' ,
text: 'Actions', value: 'name', sortable: false
]
,
async created()
this.GetInquiriesByUser()
,
methods:
async GetInquiriesByUser()
this.loading = true
try
this.records = await api.GetInquiriesByUser()
finally
this.loading = false
,
</script>
I am using router.push to route me to the user profile from the previous page (the list)
editItem(lastName)
this.$http.get(`http://localhost:61601/api/GetInquiry/$lastName`)
this.$router.push( path: `/Profile/$lastName` )
,
Here is my routes.js file - I really think my error is in this, but cant seem to figure it out.
export const routes = [
name: 'home', path: '/', component: HomePage, display: 'Home', icon: 'home' ,
name: 'AdminInquiry', path: '/Inquiry/AdminInquiry', component: AdminInquiry, display: 'Admin', icon: 'list' ,
name: 'Profile', path: `/Profile/:lastName`, component: Profile
]
vue.js routing vue-component vue-router
|
show 6 more comments
I am creating an application where I have a list of users, when I click on a single user, it takes me to that specific users profile. I am using ASP.NET Core API with Vue.js as my front end. My API is working so when I click on the user, I am able to see the data coming from my database using Chrome dev Tools and Postman. However, once my page redirects to their profile, that page is blank. When I look in dev tools, I can see that its hitting my API and getting the correct information when looking at the preview tab.
So my question is, why is my page blank and not providing me with that users information. Can someone help me look at my routing, I think that is where my issue is?
I am passing their lastName as the param, but eventually I will pass a unique id

Here is my Profile.vue page, this is where I should see the users profile
<template>
<div class="container">
<v-card>
<v-data-table :headers="headers"
:items="records"
:search="search">
<template slot="items" slot-scope="records">
<td class="text-xl-left"> records.item.firstName </td>
<td class="text-xs-left"> records.item.email </td>
<td class="text-xs-left"> records.item.phone </td>
<td class="text-xs-left"> records.item.city </td>
<td class="justify-center layout px-0"></td>
</template>
</v-data-table>
</v-card>
</div>
</template>
<script>
import api from '../store/api.js'
export default
data()
return
records: ,
headers: [
text: 'Full Name', value: 'fullName' ,
text: 'Email', value: 'email' ,
text: 'Phone', value: 'phone' ,
text: 'City', value: 'city' ,
text: 'Actions', value: 'name', sortable: false
]
,
async created()
this.GetInquiriesByUser()
,
methods:
async GetInquiriesByUser()
this.loading = true
try
this.records = await api.GetInquiriesByUser()
finally
this.loading = false
,
</script>
I am using router.push to route me to the user profile from the previous page (the list)
editItem(lastName)
this.$http.get(`http://localhost:61601/api/GetInquiry/$lastName`)
this.$router.push( path: `/Profile/$lastName` )
,
Here is my routes.js file - I really think my error is in this, but cant seem to figure it out.
export const routes = [
name: 'home', path: '/', component: HomePage, display: 'Home', icon: 'home' ,
name: 'AdminInquiry', path: '/Inquiry/AdminInquiry', component: AdminInquiry, display: 'Admin', icon: 'list' ,
name: 'Profile', path: `/Profile/:lastName`, component: Profile
]
vue.js routing vue-component vue-router
what router mode are you using?
– Daniel
Nov 15 '18 at 19:34
Do you not need to await your http call ineditItem?
– Steven B.
Nov 15 '18 at 20:40
I am using Vue.use(VueRouter). Is this what you are referring to when you mean router mode? @Daniel
– DilbarC
Nov 15 '18 at 20:41
1
@DilbarC he means history or hash mode.
– Steven B.
Nov 15 '18 at 20:44
the router has two ways it can be used, the default is thehashmode, which uses routes after the#character, the other mode ishistorywhich requires server interaction. I'm guessing you're using the hash mode. router.vuejs.org/guide/essentials/history-mode.html
– Daniel
Nov 15 '18 at 20:45
|
show 6 more comments
I am creating an application where I have a list of users, when I click on a single user, it takes me to that specific users profile. I am using ASP.NET Core API with Vue.js as my front end. My API is working so when I click on the user, I am able to see the data coming from my database using Chrome dev Tools and Postman. However, once my page redirects to their profile, that page is blank. When I look in dev tools, I can see that its hitting my API and getting the correct information when looking at the preview tab.
So my question is, why is my page blank and not providing me with that users information. Can someone help me look at my routing, I think that is where my issue is?
I am passing their lastName as the param, but eventually I will pass a unique id

Here is my Profile.vue page, this is where I should see the users profile
<template>
<div class="container">
<v-card>
<v-data-table :headers="headers"
:items="records"
:search="search">
<template slot="items" slot-scope="records">
<td class="text-xl-left"> records.item.firstName </td>
<td class="text-xs-left"> records.item.email </td>
<td class="text-xs-left"> records.item.phone </td>
<td class="text-xs-left"> records.item.city </td>
<td class="justify-center layout px-0"></td>
</template>
</v-data-table>
</v-card>
</div>
</template>
<script>
import api from '../store/api.js'
export default
data()
return
records: ,
headers: [
text: 'Full Name', value: 'fullName' ,
text: 'Email', value: 'email' ,
text: 'Phone', value: 'phone' ,
text: 'City', value: 'city' ,
text: 'Actions', value: 'name', sortable: false
]
,
async created()
this.GetInquiriesByUser()
,
methods:
async GetInquiriesByUser()
this.loading = true
try
this.records = await api.GetInquiriesByUser()
finally
this.loading = false
,
</script>
I am using router.push to route me to the user profile from the previous page (the list)
editItem(lastName)
this.$http.get(`http://localhost:61601/api/GetInquiry/$lastName`)
this.$router.push( path: `/Profile/$lastName` )
,
Here is my routes.js file - I really think my error is in this, but cant seem to figure it out.
export const routes = [
name: 'home', path: '/', component: HomePage, display: 'Home', icon: 'home' ,
name: 'AdminInquiry', path: '/Inquiry/AdminInquiry', component: AdminInquiry, display: 'Admin', icon: 'list' ,
name: 'Profile', path: `/Profile/:lastName`, component: Profile
]
vue.js routing vue-component vue-router
I am creating an application where I have a list of users, when I click on a single user, it takes me to that specific users profile. I am using ASP.NET Core API with Vue.js as my front end. My API is working so when I click on the user, I am able to see the data coming from my database using Chrome dev Tools and Postman. However, once my page redirects to their profile, that page is blank. When I look in dev tools, I can see that its hitting my API and getting the correct information when looking at the preview tab.
So my question is, why is my page blank and not providing me with that users information. Can someone help me look at my routing, I think that is where my issue is?
I am passing their lastName as the param, but eventually I will pass a unique id

Here is my Profile.vue page, this is where I should see the users profile
<template>
<div class="container">
<v-card>
<v-data-table :headers="headers"
:items="records"
:search="search">
<template slot="items" slot-scope="records">
<td class="text-xl-left"> records.item.firstName </td>
<td class="text-xs-left"> records.item.email </td>
<td class="text-xs-left"> records.item.phone </td>
<td class="text-xs-left"> records.item.city </td>
<td class="justify-center layout px-0"></td>
</template>
</v-data-table>
</v-card>
</div>
</template>
<script>
import api from '../store/api.js'
export default
data()
return
records: ,
headers: [
text: 'Full Name', value: 'fullName' ,
text: 'Email', value: 'email' ,
text: 'Phone', value: 'phone' ,
text: 'City', value: 'city' ,
text: 'Actions', value: 'name', sortable: false
]
,
async created()
this.GetInquiriesByUser()
,
methods:
async GetInquiriesByUser()
this.loading = true
try
this.records = await api.GetInquiriesByUser()
finally
this.loading = false
,
</script>
I am using router.push to route me to the user profile from the previous page (the list)
editItem(lastName)
this.$http.get(`http://localhost:61601/api/GetInquiry/$lastName`)
this.$router.push( path: `/Profile/$lastName` )
,
Here is my routes.js file - I really think my error is in this, but cant seem to figure it out.
export const routes = [
name: 'home', path: '/', component: HomePage, display: 'Home', icon: 'home' ,
name: 'AdminInquiry', path: '/Inquiry/AdminInquiry', component: AdminInquiry, display: 'Admin', icon: 'list' ,
name: 'Profile', path: `/Profile/:lastName`, component: Profile
]
vue.js routing vue-component vue-router
vue.js routing vue-component vue-router
asked Nov 15 '18 at 19:08
DilbarCDilbarC
218
218
what router mode are you using?
– Daniel
Nov 15 '18 at 19:34
Do you not need to await your http call ineditItem?
– Steven B.
Nov 15 '18 at 20:40
I am using Vue.use(VueRouter). Is this what you are referring to when you mean router mode? @Daniel
– DilbarC
Nov 15 '18 at 20:41
1
@DilbarC he means history or hash mode.
– Steven B.
Nov 15 '18 at 20:44
the router has two ways it can be used, the default is thehashmode, which uses routes after the#character, the other mode ishistorywhich requires server interaction. I'm guessing you're using the hash mode. router.vuejs.org/guide/essentials/history-mode.html
– Daniel
Nov 15 '18 at 20:45
|
show 6 more comments
what router mode are you using?
– Daniel
Nov 15 '18 at 19:34
Do you not need to await your http call ineditItem?
– Steven B.
Nov 15 '18 at 20:40
I am using Vue.use(VueRouter). Is this what you are referring to when you mean router mode? @Daniel
– DilbarC
Nov 15 '18 at 20:41
1
@DilbarC he means history or hash mode.
– Steven B.
Nov 15 '18 at 20:44
the router has two ways it can be used, the default is thehashmode, which uses routes after the#character, the other mode ishistorywhich requires server interaction. I'm guessing you're using the hash mode. router.vuejs.org/guide/essentials/history-mode.html
– Daniel
Nov 15 '18 at 20:45
what router mode are you using?
– Daniel
Nov 15 '18 at 19:34
what router mode are you using?
– Daniel
Nov 15 '18 at 19:34
Do you not need to await your http call in
editItem?– Steven B.
Nov 15 '18 at 20:40
Do you not need to await your http call in
editItem?– Steven B.
Nov 15 '18 at 20:40
I am using Vue.use(VueRouter). Is this what you are referring to when you mean router mode? @Daniel
– DilbarC
Nov 15 '18 at 20:41
I am using Vue.use(VueRouter). Is this what you are referring to when you mean router mode? @Daniel
– DilbarC
Nov 15 '18 at 20:41
1
1
@DilbarC he means history or hash mode.
– Steven B.
Nov 15 '18 at 20:44
@DilbarC he means history or hash mode.
– Steven B.
Nov 15 '18 at 20:44
the router has two ways it can be used, the default is the
hash mode, which uses routes after the # character, the other mode is history which requires server interaction. I'm guessing you're using the hash mode. router.vuejs.org/guide/essentials/history-mode.html– Daniel
Nov 15 '18 at 20:45
the router has two ways it can be used, the default is the
hash mode, which uses routes after the # character, the other mode is history which requires server interaction. I'm guessing you're using the hash mode. router.vuejs.org/guide/essentials/history-mode.html– Daniel
Nov 15 '18 at 20:45
|
show 6 more comments
1 Answer
1
active
oldest
votes
I'm guessing that this is an issue with the router setup not matching your backend. The blank page can be indicative of this.
for your vue page, the default Router mode is hash which uses a url hack, which is that changes to anything after # character (with some caveats) do not cause the browser to redirect. So when you're going from let's say localhost:80#/Inquiry/AdminInquiry to localhost:80#/Profile/Drumpf, the change is handled entirely by the vue application. If however if you navigate from localhost:80/Inquiry/AdminInquiry to localhost:80/Profile/Drumpf the navigation is more complex. The js can handle the transition by artificially changing the url without an actual redirect taking place, if the event is triggered using js. If, however, that happens using a standard anchor, your browser redirect gets triggered, and it's up to your server-side application to handle what route is passed to the js app.
It looks like you're looking to implement history mode. This requires defining the mode as history in the vue app, and making the appropriate changes for your ASP, nginx, or apache to handle the routes. More info here: https://router.vuejs.org/guide/essentials/history-mode.html
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%2f53326382%2fvue-js-routing-configuration%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I'm guessing that this is an issue with the router setup not matching your backend. The blank page can be indicative of this.
for your vue page, the default Router mode is hash which uses a url hack, which is that changes to anything after # character (with some caveats) do not cause the browser to redirect. So when you're going from let's say localhost:80#/Inquiry/AdminInquiry to localhost:80#/Profile/Drumpf, the change is handled entirely by the vue application. If however if you navigate from localhost:80/Inquiry/AdminInquiry to localhost:80/Profile/Drumpf the navigation is more complex. The js can handle the transition by artificially changing the url without an actual redirect taking place, if the event is triggered using js. If, however, that happens using a standard anchor, your browser redirect gets triggered, and it's up to your server-side application to handle what route is passed to the js app.
It looks like you're looking to implement history mode. This requires defining the mode as history in the vue app, and making the appropriate changes for your ASP, nginx, or apache to handle the routes. More info here: https://router.vuejs.org/guide/essentials/history-mode.html
add a comment |
I'm guessing that this is an issue with the router setup not matching your backend. The blank page can be indicative of this.
for your vue page, the default Router mode is hash which uses a url hack, which is that changes to anything after # character (with some caveats) do not cause the browser to redirect. So when you're going from let's say localhost:80#/Inquiry/AdminInquiry to localhost:80#/Profile/Drumpf, the change is handled entirely by the vue application. If however if you navigate from localhost:80/Inquiry/AdminInquiry to localhost:80/Profile/Drumpf the navigation is more complex. The js can handle the transition by artificially changing the url without an actual redirect taking place, if the event is triggered using js. If, however, that happens using a standard anchor, your browser redirect gets triggered, and it's up to your server-side application to handle what route is passed to the js app.
It looks like you're looking to implement history mode. This requires defining the mode as history in the vue app, and making the appropriate changes for your ASP, nginx, or apache to handle the routes. More info here: https://router.vuejs.org/guide/essentials/history-mode.html
add a comment |
I'm guessing that this is an issue with the router setup not matching your backend. The blank page can be indicative of this.
for your vue page, the default Router mode is hash which uses a url hack, which is that changes to anything after # character (with some caveats) do not cause the browser to redirect. So when you're going from let's say localhost:80#/Inquiry/AdminInquiry to localhost:80#/Profile/Drumpf, the change is handled entirely by the vue application. If however if you navigate from localhost:80/Inquiry/AdminInquiry to localhost:80/Profile/Drumpf the navigation is more complex. The js can handle the transition by artificially changing the url without an actual redirect taking place, if the event is triggered using js. If, however, that happens using a standard anchor, your browser redirect gets triggered, and it's up to your server-side application to handle what route is passed to the js app.
It looks like you're looking to implement history mode. This requires defining the mode as history in the vue app, and making the appropriate changes for your ASP, nginx, or apache to handle the routes. More info here: https://router.vuejs.org/guide/essentials/history-mode.html
I'm guessing that this is an issue with the router setup not matching your backend. The blank page can be indicative of this.
for your vue page, the default Router mode is hash which uses a url hack, which is that changes to anything after # character (with some caveats) do not cause the browser to redirect. So when you're going from let's say localhost:80#/Inquiry/AdminInquiry to localhost:80#/Profile/Drumpf, the change is handled entirely by the vue application. If however if you navigate from localhost:80/Inquiry/AdminInquiry to localhost:80/Profile/Drumpf the navigation is more complex. The js can handle the transition by artificially changing the url without an actual redirect taking place, if the event is triggered using js. If, however, that happens using a standard anchor, your browser redirect gets triggered, and it's up to your server-side application to handle what route is passed to the js app.
It looks like you're looking to implement history mode. This requires defining the mode as history in the vue app, and making the appropriate changes for your ASP, nginx, or apache to handle the routes. More info here: https://router.vuejs.org/guide/essentials/history-mode.html
answered Nov 15 '18 at 21:00
DanielDaniel
11.7k95099
11.7k95099
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%2f53326382%2fvue-js-routing-configuration%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
what router mode are you using?
– Daniel
Nov 15 '18 at 19:34
Do you not need to await your http call in
editItem?– Steven B.
Nov 15 '18 at 20:40
I am using Vue.use(VueRouter). Is this what you are referring to when you mean router mode? @Daniel
– DilbarC
Nov 15 '18 at 20:41
1
@DilbarC he means history or hash mode.
– Steven B.
Nov 15 '18 at 20:44
the router has two ways it can be used, the default is the
hashmode, which uses routes after the#character, the other mode ishistorywhich requires server interaction. I'm guessing you're using the hash mode. router.vuejs.org/guide/essentials/history-mode.html– Daniel
Nov 15 '18 at 20:45