1.

const router = new VueRouter({         routes: [           { path: '/user/:name', component: User }            { path: '/user/:name', component: Admin }           { path: '/user/:name', component: Customer }         ]       }) 

Answer»

All properties defined in Vue instances are reactive. It means that the components are automatically updated and re-rendered in case of changes at any instance. 

All these properties will change to getters and setters in the initialization stage.  

Following setbacks should be considered while designing a Vue app; 

JavaScript LIMITATIONS: Vue cannot detect the deletion or addition of an object property. Vue performs the getter/setter CONVERSION process during instance initialization; property must be PRESENT in the data object for Vue to convert it and make it reactive.  

Example: 

VAR vm = new Vue({    data: {   a: 1   }  })  // `vm.a` is now reactive  vm.b = 2  // `vm.b` is NOT reactive 

Additionally, it cannot detect the modification of array items. Vue does not ALLOW adding new root-level reactive properties to a created instance.  

It is feasible to add reactive properties to a nested object using the Vue.set(object, propertyName, value) method, as shown below. 

Vue.set(vm.someObject, 'b', 2)


Discussion

No Comment Found

Related InterviewSolutions