[Vuejs]-I need to route to another page after login in vuejs

0๐Ÿ‘

If you have single Vue instance for your routes, you can use this.$router.push({ name: 'component' }):

methods: {
        check() {
        if( this.email == 'admin' && this.password == 'admin'){
           this.$router.push({ name: 'dashboard' });
           //OR with relative path
           this.$router.push({ path: '/dashboard' });
          }
         }
         ...

0๐Ÿ‘

If you want you can easily to do that with this:

check() {
   if( this.email == 'admin' && this.password == 'admin'){
        window.location = "/dashboard"
    }
}

Leave a comment