添加一个进度条的效果,可以在路由跳转时使用
添加插件
- yarn add nprogress
- npm install --save nprogress
router引入
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
before
调用、after
结束
router.beforeEach((to, from, next) => {
NProgress.start()
next()
})
router.afterEach(() => {
NProgress.done()
})