Home  >  Article  >  Web Front-end  >  How to refresh the page in vue.js

How to refresh the page in vue.js

coldplay.xixi
coldplay.xixiOriginal
2020-11-10 14:47:167604browse

Vue.js method of refreshing the page: 1. Refresh the entire page directly, the code is [location. reload()]; 2. Create a new blank page [supplierAllBack.vue], and jump when you click OK Go to this blank page and jump back immediately.

How to refresh the page in vue.js

【Related article recommendations: vue.js

vue.js Refresh the page Method:

1. The most direct way to refresh the entire page:

How to refresh the page in vue.js

location. reload()
this.$router.go(0)

Both of these two methods can refresh the current page, but the disadvantage is that they are quite If you press ctrl F5 to force refresh, the entire page will be reloaded, and a momentary blank page will appear. The experience is not good

2. Create a new blank page supplierAllBack.vue. When you click OK, jump to this first. Blank page, and then jump back immediately

How to refresh the page in vue.js

Blank pageThe content in supplierAllBack.vue:

How to refresh the page in vue.js

This method , compared to the first method, a blank page will not appear for a moment, but there is a quick switching process in the address bar. You can use

3. The provide / inject combination is the most practical one I have tried. Below Let me explain to you with a screenshot of the project: First, modify your app.vue

How to refresh the page in vue.js

by declaring the reload method to control the display or hiding of router-view, thereby controlling the page. To load again,

isRouterAlive //true or false is defined here to control

and then inject the App.vue component into the page that needs to refresh the current page to provide ( provide)'s reload dependency, and then use this.reload to call it directly

How to refresh the page in vue.js

Related free learning recommendations:JavaScript(Video)

The above is the detailed content of How to refresh the page in vue.js. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn