Vinh Hung Nguyen
Vinh Hung Nguyen

Reputation: 148

How to completely refresh a page right when navigating to it?

I would like to refresh a page (same effect as click Command+R on Mac OS) when navigating to that page.

For example:

I have "abc.com/login" for the Login page which will navigate to "abc.com/dashboard" for Dashboard after login successfully. At the moment, it navigates to the Dashboard without completely refresh the whole page.

I would like it to completely refresh everything. By "refresh", I mean it is the same as clicking Command+R on the browser.

Upvotes: 1

Views: 1595

Answers (4)

Andy
Andy

Reputation: 5414

You can use vue built-in forceUpdate function, like this:

vm.$forceUpdate()

or if it's inside the component, you can use

this.$forceUpdate();

References:

Upvotes: 0

Hardik Raval
Hardik Raval

Reputation: 3641

this.$router.go() without parameter will reload the page.

Upvotes: 1

Prabhakaran
Prabhakaran

Reputation: 3999

You can use something like this

window.location.href = "/dashboard?key=" + Math.random()

Instead of Math.random() something else can be used if required

Upvotes: 0

Luke
Luke

Reputation: 614

Try:

window.location.reload(true);

Passing true to the reload function will force the page to reload from the server. Alternatively, pass false to reload from cache. This is vanilla javascript so it is not a vueJS only solution.

Upvotes: 0

Related Questions