Vue-router – Routing using Vuejs – Dynamic Components in Vuejs

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.

READ :  Angularjs Convert Comma separated String To Array Example

routes: [
  {path: '/', component: PeopleListing},
  {name: 'person', path: '/:id', component: PersonDetail}
]

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.

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

Vue-router Example – Dynamic Components in Vue.js

const NotFound = { template: '<p>Simple Page not found</p>' }
const products = { template: '<p>products page</p>' }
const services = { template: '<p>services page</p>' }
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) }
})

Example

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.

READ :  vue-resource vue resource post data - AJAX requests Vuejs

Add a Comment

Your email address will not be published. Required fields are marked *