Load component / template depending on route param vuejs
I would like to ask if I can implement this in vuejs, so basically the code will load the page / template base on the param url. I've been looking for a while and can't get the results I want, or maybe I'm just looking for the wrong keyword.
My url is like this, so I just cannot manually declare the url in my route because it is dynamic, retrieved from the database.
path: '/user/page_type
Many thanks!
export default {
mounted () {
if(this.$routes.params.page_type == "home"){
// Load Homepage Here
// ../../../page/HomePage.vue
}
else if(this.$routes.params.page_type == "speaker"){
// Load Speakerpage Here
// ../../../page/HomePage.vue
}
else if(this.$routes.params.page_type == 'html'){
// Load HTML Page Here
// ../../../page/HtmlPage.vue
}
}
}
+3
source to share