In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "Vue how to refresh the page", the editor shows you the operation process through the actual case, the operation method is simple and fast, practical, I hope this "Vue how to refresh the page" article can help you solve the problem.
When we are writing a project, we often encounter that the user needs to refresh the page to re-render the page after performing an action and changing some state. Such as: user login success, add, delete, update and so on.
Original method:
Location.reload ()
Route redirection that comes with vue:
This.$router.go (0)
People who have used it all know that the first two are forced to refresh the page, there will be a brief flicker, the user experience is not good.
So, we choose the third way:
First, write the following code in App:
Export default {name: 'App', provide () {/ / provides variables in the parent component through provide, and injects variables in the child component through inject. Return {reload: this.reload}}, data () {return {isRouterAlive: true / / variables that control whether the view is displayed}} Methods: {reload () {this.isRouterAlive = false / / close first, this.$nextTick (function () {this.isRouterAlive = true; / / reopen})}},}
Next, we can write this in the component that needs to refresh the page:
Export default {inject: ['reload'], / / inject the reload method data () {return {. }}, this is the end of the content about "how to refresh the page with Vue". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.