I have a page that has a router-view component in it. I also have a button in the parent page that when I click it I perform a router.push() and send in some objects to a named route via params. It works great. However if a user clicks F5 to do a page refresh I am no longer able to obviously send in the necessary object to the my named route because I can't capture the page refresh. I've debugged it and the named route component gets mounted before my parent page is mounted and there doesn't seem to be any way to notify the component in my route of the objects it needs from the parent. Is it that routes are not expected to be tightly coupled to the parent component? Thanks.
-- Parent component --
<button v-on:click="buttonClick">Get Tests</button>
<router-view></router-view>
...
const router = new VueRouter({
mode: history,
routes: [
{
path: "/school/:id/tests",
name: "tests",
component: testcomp,
props: true
}]
});
new Vue ({
router,
methods: {
buttonClick: function()
{
// ajax call to get tests
// promise return
.then( ret =>
{
router.push(
{
name: "tests",
params: {
allTests: ret.tests,
id: 99,
}
});
})
},
},
});
-- Child component --
...
props : {
allTests: []
},
mounted: function()
{
// fill in table with this.allTests
}
users/:id
? As the route can refresh to fetch data according object that has same userID? And vue-router has location history mode to be enabled, so nothing wrong for my side of featching data even page refresh. – SC Kim