博客
关于我
vue结合nprogress如何添加响应进度条的效果
阅读量:370 次
发布时间:2019-03-05

本文共 596 字,大约阅读时间需要 1 分钟。

一、vue 使用 nprogress 添加进度条的效果

  1. 通过 npm install --save nprogress 命令下载 nprogress 工具包
  2. 导入 nprogress包,以及对应的 jscss文件,代码如下:
// 导入 nprogress 包对应的js和cssimport NProgress from 'nprogress'import 'nprogress/nprogress.css'
  1. request 拦截器中,展示进度条, NProgress.start(),代码如下:
axios.interceptors.request.use(config => {     // 展示进度条  NProgress.start()  // 为请求头对象,添加Token验证的Authorization  config.headers.Authorization = window.sessionStorage.getItem('token')  // 最后必须返回config  return config})
  1. response 拦截器中,隐藏进度条, NProgress.done(),代码如下:
axios.interceptors.response.use(config => {     NProgress.done()  return config})

转载地址:http://pcpg.baihongyu.com/

你可能感兴趣的文章
Nginx模块 ngx_http_limit_conn_module 限制连接数
查看>>
Nginx模块 ngx_http_limit_req_module 限制请求速率
查看>>
nginx添加允许跨域header头
查看>>
nginx添加模块与https支持
查看>>
nginx状态监控
查看>>
Nginx用户认证
查看>>
Nginx的location匹配规则的关键问题详解
查看>>
Nginx的Rewrite正则表达式,匹配非某单词
查看>>
Nginx的使用总结(一)
查看>>
Nginx的使用总结(三)
查看>>
Nginx的使用总结(二)
查看>>
Nginx的使用总结(四)
查看>>
Nginx的可视化神器nginx-gui的下载配置和使用
查看>>
nginx的平滑升级方法:
查看>>
Nginx的是什么?干什么用的?
查看>>
Nginx的端口修改问题
查看>>
nginx看这一篇文章就够了
查看>>
Nginx知识详解(理论+实战更易懂)
查看>>
Nginx简单介绍
查看>>
Nginx系列6之-rewirte功能使用案例总结
查看>>