Vue use NProgress

NProgress is a page jump is seen in the progress bar at the top of the browser 
's official website: http://ricostacruz.com/nprogress/ 
GitHub: https://github.com/rstacruz/nprogress

 

Green progress bar is to NProgressachieve results 

installation

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

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

use

//导入
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

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

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

In App.vuethe styleincrease:

    .bar {#nprogress 
      background: Red ! Important; // custom color 
    }

 

Guess you like

Origin www.cnblogs.com/xiaoxiao2017/p/11317939.html