https://blog.csdn.net/qq_40954793/article/details/84957643

1,安装

npm install --save nprogress

2,引入,例如要在切换路由,加载页面时实现进度条

router.beforeEach((to, from, next) => {
  NProgress.start()
  next()
})
 
router.afterEach(() => {
  NProgress.done()
})
3,在进行ajax请求时出现进度条

//interceptors拦截器
Vue.http.interceptors.push((request, next) => {  
  NProgress.start();
 
  next((response)=>{
    NProgress.done();
  });
});

 

相关文章:

  • 2021-06-07
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
猜你喜欢
  • 2020-04-17
  • 2021-09-23
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案