Home > front end >  What is the equivalent window.location.href for vue router
What is the equivalent window.location.href for vue router

Time:09-09

I want to redirect to a page in my spa after an action in my small vue app. If I do this with window.location.href = "/subpage" the page refreshes and I lose cached data from my simple storage management.

The goal is to redirect without refreshing.

CodePudding user response:

You can use Vue router, and use the router-link component.

<router-link to="/subpage">Sub page</router-link>

Or dynamically via javascript.

this.$router.push('/subpage');
  • Related