Vuejs Nested Templates and Components using Nested Router

Vuejs Nested Templates and Components using Nested Router

In this Post We Will Explain About is Vuejs Nested Templates and Components using Nested Router 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 javascript – Vuejs nested components, templates, and using Modals

In this post we will show you Best way to implement javascript – VueJS nested components, hear for How to javascript – Vuejs nested components with inline-template with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

READ :  Vuejs Implementing Routes And Multiple Views Example

Vuejs Example : index.html

First of all you create a multiple template or multiple Components using vuejs ad the also CSS Applay this both two way data bindnig and template.

<div class="container">
    <a href="#student">People</a>
    </br> 
           
</div>


  <p>{{name}}</p>
  
  <button>Save</button>



  <a href="#student/1">student 1</a>
  <a href="#student/2">student 2</a>
  </br>
  


index.js

here learn to vuejs router to all template dynemic data show and hide using vuejs templates.

var router = new VueRouter()

var App = Vue.extend({})

var student = {
  '1': {
    name: 'student 1',
    dirty: false
  },
  '2': {
    name: 'student 2',
    dirty: false
  }
}

var studentComponent = Vue.extend({
  template: '#student-template',
  data: {
    name: "A student",
    dirty: false
  },
  methods: {
    nameChanged: function() {
      this.dirty = true;
    },
    save: function() {
      this.dirty = false;
    }
  },
  route: {
    data: function(transition) {      
      return student[transition.to.params.id];
    },
    canReuse: false,
    activate: function(transition) {
      console.log('activate', this.name)
      transition.next()
    },
    canDeactivate: function () {
      if (this.dirty) {
        alert('simple Changes not saved for infinityknow.com')
        return false;
      }
    }
  }
});

var StudComponent = Vue.extend({
  template: '#student-template'
});

router.map({
  '/student': {
    component: StudComponent,
    subRoutes: {
      '/:id': {
        component: studentComponent       

      }
    }
  }
})

router.start(App, 'body')

Example

READ :  Include common header and footer using Vuejs - router-view

I hope you have Got javascript – Vuejs nested components, templates, and using Modals 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.

https://pakainfo.com/

Add a Comment

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