实现导航栏吸顶操作

news/2024/7/10 3:20:48 标签: 前端, vue, elementui

一、使用vueuse.org/guide/" rel="nofollow">VueUse插件

// 安装
npm i @vueuse/core

二、点击搜索vueuse.org/core/useScroll/#usescroll" rel="nofollow">useScroll

2.1搜索结果如图
在这里插入图片描述

三、使用

// 这是示例代码
import { useScroll } from '@vueuse/core'
const el = ref<HTMLElement | null>(null)
const { x, y, isScrolling, arrivedState, directions } = useScroll(el)
// 我自己的代码
import { useScroll } from '@vueuse/core';
// 直接解构赋值拿到 当鼠标向下滑动时滑动的距离
const { y } = useScroll(window);
// html结构代码
<div class="box" :class="{flotbox: y > 100}"> 
    <div class="box_l">
      <img v-if="y > 100" src="@/assets/indexLogo1.png" alt="">
      <img v-else src="@/assets/indexLogo.png" alt="">
    </div>
    <div class="box_c">
      <el-menu
        :default-active="activeIndex"
        class="el-menu-demo"
        mode="horizontal"
        @select="handleSelect"
      >
        <el-menu-item index="1">首页</el-menu-item>
        <el-menu-item index="2">产品技术</el-menu-item>
        <el-menu-item index="3">解决方案</el-menu-item>
        <el-menu-item index="4">行业洞见</el-menu-item>
        <el-menu-item index="5">关于我们</el-menu-item>
      </el-menu>
    </div>
// css核心代码 使用的是固定定位
.box {
  position: fixed;
  top: 0;
  left: 0;
}

四、当鼠标向下滑动超过100像素时导航栏切换样式
在这里插入图片描述
在这里插入图片描述


http://www.niftyadmin.cn/n/5316109.html

相关文章

序列模型(4)—— Scaling Laws

本文介绍 LLM 训练过程中重要的 Scaling Laws&#xff0c;这是一个经验规律&#xff0c;指出了固定训练成本&#xff08;总计算量FLOPs&#xff09; C C C 时&#xff0c;如何调配模型规模&#xff08;参数量&#xff09; N N N 和训练 Token 数据量 D D D&#xff0c;才能实现…

向量数据库:Milvus

特性 Milvus由Go(63.4%),Python(17.0%),C(16.6%),Shell(1.3%)等语言开发开发&#xff0c;支持python&#xff0c;go&#xff0c;java接口(C,Rust,c#等语言还在开发中)&#xff0c;支持单机、集群部署&#xff0c;支持CPU、GPU运算。Milvus 中的所有搜索和查询操作都在内存中执行…

04- OpenCV:Mat对象简介和使用

目录 1、Mat对象与IplImage对象 2、Mat对象使用 3、Mat定义数组 4、相关的代码演示 1、Mat对象与IplImage对象 先看看Mat对象&#xff1a;图片在计算机眼里都是一个二维数组&#xff1b; 在OpenCV中&#xff0c;Mat是一个非常重要的类&#xff0c;用于表示图像或矩阵数据。…

高校站群内容管理系统开发语言各有优势

站群管理系统开发可以选择多种编程语言&#xff0c;具体选择哪种语言最好需要考虑多个因素&#xff0c;包括开发团队的技术栈、项目需求、性能要求、安全性等。下面列举一些常见的编程语言及其适用场景&#xff1a; PHP&#xff1a;PHP是一种广泛使用的服务器端脚本语言&#…

flutter资源

开发者平台 腾讯云 https://cloud.tencent.com/developer/article/1902681 掘金 stackoverflow 个人博主 Magic旭 https://www.jianshu.com/u/f9b0b77d6038 J船长 https://juejin.cn/user/1820446987136903/posts 老孟 http://www.laomengit.com/flutter/widgets/Theme.html#t…

MYSQL篇--事务机制高频面试题

事务 1 什么是数据库事务&#xff1f; 事务是一个不可分割的数据库操作序列&#xff0c;也是数据库并发控制的基本单位&#xff0c;其执行的结果必须使数据库从一种一致性状态变到另一种一致性状态。事务是逻辑上的一组操作&#xff0c;要么都执行&#xff0c;要么都不执行。…

系统存储架构升级分享

一、业务背景 系统业务功能&#xff1a;系统内部进行数据处理及整合, 对外部系统提供结果数据的初始化(写)及查询数据结果服务。 系统网络架构: • 部署架构对切量上线的影响 - 内部管理系统上线对其他系统的读业务无影响 •分布式缓存可进行单独扩容, 与存储及查询功能升级…

jmeter监控服务器资源使用情况

GitHub - undera/perfmon-agent: Server metrics fetching agent, based on SIGAR 下载安装包&#xff1a;ServerAgent-2.2.3.zip 解压先 启动&#xff0c;如果是windows运行startAgent.bat&#xff0c;如果是linux运行startAgent.sh 注意&#xff1a;linux上注意权限的问题…