What is the equivalent window.location.href for vue router

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.

>Solution :

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');

Leave a Reply