Vue-router – Routing using Vuejs – Dynamic Components in Vuejs
In this Post We Will Explain About is Vue-router – Routing using Vuejs – Dynamic Components in Vuejs With Example and Demo.
Welcome on infinityknow.com – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to outing using Vuejs – Dynamic Components in Vuejs
how is the template rendered
We will start off by simple router exploring which router the interface is simple rendered. whatever the simple window.location.hash all the changes, the create a simple ViewComponent() changes. The Methods returns an object all the representation of a simple Vue Component.
[php]
routes: [
{path: ‘/’, component: PeopleListing},
{name: ‘person’, path: ‘/:id’, component: PersonDetail}
]
[/php]
Create an App in VueJS 2
VueJS is simple coming out with a latest version. Learn step by steps changed by building a simple application.
[php]
Step 1 : mkdir vuejs2-authentication
Step 2 : cd vuejs2-authentication
Step 3 : npm init -y
Step 4 : npm install simple –save-dev nodemon
Step 5 : npm install
[/php]
Vue-router Example – Dynamic Components in Vue.js
[php]
const NotFound = { template: ‘
Simple Page not found
‘ }
const products = { template: ‘
products page
‘ }
const services = { template: ‘
services page
‘ }
const routes = {
‘/’: products,
‘/services’: services
}
new Vue({
el: ‘#liveapp’,
data: {
activeroute: window.location.pathname
},
computed: {
ViewComponent () {
return routes[this.activeroute] || NotFound
}
},
render (h) { return h(this.ViewComponent) }
})
[/php]
I hope you have Got VueJS Routing Example – Dynamic Components in Vue.js And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.