如何在vue 2中更改路由器时显示加载微调器 [英] how can I show loading spinner when changing router in vue 2
本文介绍了如何在vue 2中更改路由器时显示加载微调器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直试图在vue 2中的每个路由器更改上显示一个微调器。我在创建的方法中添加了一个标志来显示初始加载,并且在某个时候我停止了加载微调器。这根本不起作用。
I have been trying to show a spinner on each router change in vue 2. I added a flag in created method to show the initial loading and after sometime I stopped the loading spinner. This doesn't work at all.
有没有其他解决方案来实现这一目标?
Is there any other solution to achieve this?
提前致谢。
推荐答案
您还可以使用导航防护设置在进入每条新路线之前运行的beforeEach方法: https://router.vuejs.org/en/advanced/navigation-guards.html
You can also use navigation guards to set a beforeEach method that will run before entering each new route: https://router.vuejs.org/en/advanced/navigation-guards.html
这篇关于如何在vue 2中更改路由器时显示加载微调器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文