vue3学习——路由进度条

安装

pnpm i nprogress

创建permission.ts

import router from '@/router/index.ts'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css' // 不加样式不显示
NProgress.configure({ showSpinner: false })
router.beforeEach((to, from, next) => {
  console.log(to, from)
  NProgress.start()
  next()
})
router.afterEach((to, from, next) => {
  console.log(to, from)
  NProgress.done()
})

main.ts 中引入

import '/permission.ts'

你可能感兴趣的:(vue3,学习,vue3)