Programmatically navigating with, redirecting, and adding an alias
While building your app, there may be situations that require some different navigation techniques. These may be navigating programmatically, for example in a component or the main Vue instance, redirecting users when they hit a specific URL, or loading the same component with various URLs.
Navigating programmatically
You may want to alter the path, URL, or user flow from the code, a component, or action. An example of this might be sending the user to the basket after they've added an item.
To do this, you use a push()
function on the router instance. The value of push can either be a string for a direct URL or it can accept an object to pass named routes or route parameters. The allowed contents of the push
function are exactly the same as the to=""
attribute on the router-link
element. For example:
const About = { name: 'About', template: '#about', methods: { someAction() { /* Some code here */ // direct...