be.af.loading.js 536 B

123456789101112131415161718
  1. import { PluginLoading } from "../components/other/VpLoading";
  2. /**
  3. * 路由导航前后处理 路由载入等待
  4. * @param router 路由实例
  5. */
  6. export const beforeAfterEachForLoading = router => {
  7. router.beforeEach((to, from, next) => {
  8. clearTimeout(beforeAfterEachForLoading.inter);
  9. PluginLoading.open({ text: "载入中" });
  10. next();
  11. });
  12. router.afterEach(() => {
  13. clearTimeout(beforeAfterEachForLoading.inter);
  14. beforeAfterEachForLoading.inter = setTimeout(() => PluginLoading.close(true));
  15. });
  16. };