Router push in vue.js

You can access the router instance as $router in Vue instance. Then call

$this.$router.push

You can use router.push to navigate to different URLs. router.push method pushes a new entry to history so when the user clicks the back button on the browser they will be redirected to the previous URL. When you click <router-link> it's equivalent to router.push. The argument can be a string path or location descriptor object.

// literal string path
router.push('home')

// object
router.push({ path: 'home' })

// named route
router.push({ name: 'user', params: { userId: '123' } })

// with query, resulting in /register?plan=private
router.push({ path: 'register', query: { plan: 'private' } })

If the path is already provided the params will not be considered. The same applies to router-link components also. In version 2.2.0 provide onComplete and onAbort as optional callbacks to router.push or router.replace as second and third arguments. In 3.1.0+ you don’t have to add 2nd and 3rd parameters.