[Vuejs]-Could Vue.js router-view name be changed?

0👍

You need dynamic components for this,

Html code

<template>
   <div id="app"> 
    <router-view :is="currentComponent"></router-view>
   </div>
 </template> 

Js code: here depending on isTrue value set whichever component you need.

<script>
export default {
  name: 'App' ,
  components: { 
   LoginComponent,
   HelloComponent
   },
   computed: { 
   currentComponent () { 
    return isTrue ? 'HelloComponent' :  'LoginComponent'
     }
    }

}
  </script>

Leave a comment