Vue插件使用NProgress

NProgress是页面跳转是出现在浏览器顶部的进度条

官网:http://ricostacruz.com/nprogress/
github:https://github.com/rstacruz/nprogress

安装

$ npm install --save nprogress 或者
$ yarn add nprogress

//用法
NProgress.start();
NProgress.done();

使用

复制代码
//导入
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

router.beforeEach((to, from, next) => {
    
    
  NProgress.start()
  next()
})

router.afterEach(() => {
    
    
  NProgress.done()
})  

修改颜色 在App.vue中的style中增加:

    #nprogress .bar {
    
    
      background: red !important; //自定义颜色
    }
    ```

猜你喜欢

转载自blog.csdn.net/weixin_45264424/article/details/109218385