VUE3项目--路由切换时展示进度条

在路由组件切换时,展示进度条。

一、安装进度条插件nprogress

1、安装

官网:www.npmjs.com/package/npr... pnpm intall --save nprogress

2、引入

在要是使用进度条的ts文件中,引入nprogress

javascript 复制代码
// *.ts

// 引入进度条
import nprogress from 'nprogress'
// 引入进度条样式
import 'nprogress/nprogress.css'

3、使用

scss 复制代码
// 进度条开始
nprogress.start()

// 进度条完成
nprogress.done()

二、配置进度条样式

1、修改进度条的背景色

在/node_modules/nprogress/nprogress.css中,修改进度条的背景色

css 复制代码
// nprogress.css

#nprogress .bar {
  /* background: #29d; */
  /* 渐变式背景色 */
  background-image: linear-gradient(to right, red, cyan, yellow, pink);

  position: fixed;
  z-index: 1031;
  top: 0;
  left: 0;

  width: 100%;
  height: 2px;
}
相关推荐
狗头大军之江苏分军7 小时前
Node.js 原生功能越来越强,我们是不是被 npm 玩坏了?
前端·javascript·架构
独自破碎E7 小时前
TS7016: Could not find a declaration file for module ‘vue-router‘.解决办法
前端·javascript·vue.js
仰望星空@脚踏实地7 小时前
DataKit js-yaml和follow-redirects组件依赖影响分析
前端·datakit
Mr_fang719407 小时前
iframe 导致 Vue Router go(-1) 无法正常返回问题解决方案
前端
Drift_Dream7 小时前
Node.js 第二课:用核心模块构建你的第一个服务器
前端·后端
DEMO派7 小时前
首页图片懒加载实现方案解析
前端
用户952081611797 小时前
百度地图MapVThree Editor:地图编辑
前端
程序员龙语8 小时前
CSS 文本样式与阴影属性
前端·css
LYFlied8 小时前
【每日算法】LeetCode 152. 乘积最大子数组(动态规划)
前端·算法·leetcode·动态规划
狼与自由8 小时前
excel 导入 科学计数法问题处理
java·前端·excel