vue2实现tabs侧边导航栏点击内容跳转到对应位置,且内容滚动导航栏切换对应tab

1、tabs使用了 element的插件tabs, 省的自己写滑动动画

2、左侧有用到了 element的插件 NavMenu导航菜单,项目涉及到了切换页面

效果图:

<template>
<div class="updateDesc_wrapper">
<div class="updateDesc_con">
<div class="update_left">
<div class="update_img">
<img class="updateImg" src="@/assets/image/update-desc/updateImg.png" />
</div>
<div class="update_menu">
<el-menu default-active="1-1" class="el-menu-vertical-demo updateMenu">
<el-submenu index="1">
<template slot="title">
<span>更新说明</span>
</template>
<el-menu-item-group>
<el-menu-item index="1-1">
<img class="img1" src="@/assets/image/update-desc/updateIcon1.png" />
<img class="img2" src="@/assets/image/update-desc/updateIcon2.png" />
<span>2022-12-30 首页更新说明</span>
</el-menu-item>
<!-- <el-menu-item index="1-2">
<img class="img1" src="@/assets/image/update-desc/updateIcon1.png" />
<img class="img2" src="@/assets/image/update-desc/updateIcon2.png" />
<span>2022-12-30 首页更新说明</span>
</el-menu-item> -->
</el-menu-item-group>
</el-submenu>
</el-menu>
</div>
</div>
<div class="update_right">
<div class="update_conten" ref="content_wrapper">
<div class="conten_tit">
<span class="tit_text">首页更新说明</span>
<span class="tit_date">发布日期:2022-12-15</span>
</div>
<div class="conten_info">
<div class="content_wrapper">
<div ref="cont_1" class="roll_box">
<div class="con_tit">
1. 侧边导航优化,全新交互体验
</div>
<div class="con_info">
<img src="@/assets/image/update-desc/updateSy1.png" />
</div>
</div>
<div ref="cont_2" class="roll_box">
<div class="con_tit">
2. 综合搜索升级:全局统一,轻松查询
</div>
<div class="con_info">
<p>查企业、查业务、查空壳、查集团 、查政策 、查产业、查研报、查舆情、查融资、查功能</p>
<img src="@/assets/image/update-desc/updateSy2.png" />
<p><strong>搜索联想功能及搜索结果展示,</strong>同时页面右侧提供历史记录和推荐卡片快捷功能,进一步提升用户体验。</p>
<img src="@/assets/image/update-desc/updateSy3.png" />
</div>
</div>
<div ref="cont_3" class="roll_box">
<div class="con_tit">
3. 自定义功能入口
</div>
<div class="con_info">
<p>根据用户偏好自定义添加快速入口;点击更多可进入“全部功能”页面并支持搜索。</p>
<img src="@/assets/image/update-desc/updateSy4.png" />
</div>
</div>
<div ref="cont_4" class="roll_box">
<div class="con_tit">
4. 上线“更新说明”
</div>
<div class="con_info">
<img src="@/assets/image/update-desc/updateSy5.png" />
</div>
</div>
</div>
</div>
</div>
<div class="update_tab">
<el-tabs tab-position="right" class="updateTab" @tab-click="scrollTo" :activeName="isScrollNow"
style="height: fit-content;">
<el-tab-pane label="1. 侧边导航优化" name="0"></el-tab-pane>
<el-tab-pane label="2. 综合搜索升级" name="1"></el-tab-pane>
<el-tab-pane label="3. 自定义功能入口" name="2"></el-tab-pane>
<el-tab-pane label="4. 上线“更新说明”" name="3"></el-tab-pane>
</el-tabs>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'update-desc',
components: {
},
data() {
return {
isScrollNow: '0'
}
},
mounted() {
window.addEventListener('scroll', this.onScroll, true)
},
created() {
window.removeEventListener('scroll', this.onScroll, false)
},
methods: {
// 右侧跳转方法
scrollTo(tab) {
document.getElementsByClassName('roll_box')[tab.index].scrollIntoView({
behavior: 'smooth',
block: 'start',
})
},
// 内容部分滚动方法
onScroll() {
const navContents = document.querySelectorAll('.roll_box')
const offsetTopArr = []
navContents.forEach((item) => {
offsetTopArr.push(item.offsetTop)
})
const scrollTop = this.$refs.content_wrapper.scrollTop + 240
let navIndex = 0
for (let n = 0; n < offsetTopArr.length; n++) {
if (scrollTop >= offsetTopArr[n]) {
navIndex = n
this.isScrollNow = String(navIndex)
// 滑动底部选中最后一个选项
if (
this.$refs.content_wrapper.scrollHeight
- this.$refs.content_wrapper.scrollTop
<= this.$refs.content_wrapper.clientHeight + 50
) {
this.isScrollNow = String(offsetTopArr.length - 1)
}
}
}
},
},
}
</script> <style lang="less" scoped>
.updateDesc_wrapper {
height: 100%; .updateDesc_con {
display: flex;
justify-content: space-between;
background: #fff;
height: 100%; .update_left {
width: 240px;
border-right: 1px solid rgba(229, 230, 235, 0.7); .update_img {
width: 100%; .updateImg {
width: 100%;
}
} .update_menu {
width: 100%; /deep/ .updateMenu {
border-right: none; .el-submenu__title {
padding: 0 !important;
padding-left: 40px !important;
text-align: left;
color: #1D2128;
height: 40px;
line-height: 40px;
} .el-menu-item-group__title {
display: none;
} .el-submenu__icon-arrow {
color: transparent;
background: url(../../assets/image/update-desc/updateIcon3.png) no-repeat;
background-size: contain;
position: absolute;
top: 50%;
right: inherit;
left: 25px;
margin-top: -5px;
font-size: 14px;
display: block;
width: 8px;
} .el-submenu.is-opened>.el-submenu__title .el-submenu__icon-arrow {
transform: rotateZ(90deg);
} .el-submenu .el-menu-item {
height: 32px;
line-height: 32px;
border-left: 2px solid #fff;
padding: 0 20px 0 40px !important;
text-align: left; img {
width: 11px;
} .img2 {
display: none;
} span {
font-size: 12px;
color: #1D2128;
margin-left: 10px;
} &.is-active {
background: #D1E2FF;
border-left: 2px solid #2D5CF6; .img1 {
display: none;
} .img2 {
display: inline;
} span {
color: #2D5CF6;
}
}
}
}
}
} .update_right {
width: calc(100% - 240px);
height: 100%;
display: flex;
justify-content: space-between; .update_conten {
width: calc(100% - 240px);
height: 100%;
overflow-y: auto;
padding: 24px 60px;
box-sizing: border-box; .conten_tit {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 16px;
border-bottom: 1px solid #E5E6EB; .tit_text {
font-weight: 700;
font-size: 20px;
line-height: 28px;
color: #1D2128;
} .tit_date {
font-size: 14px;
line-height: 22px;
color: #86909C; }
} .conten_info {
width: 100%; .content_wrapper {
.roll_box {
text-align: left; .con_tit {
margin-top: 24px;
font-weight: 700;
font-size: 16px;
line-height: 24px;
color: #2D5CF6;
position: relative; &::before {
content: "";
position: absolute;
display: block;
width: 16px;
height: 16px;
border-radius: 50%;
left: -6px;
top: 0px;
background: linear-gradient(90deg, rgba(123, 97, 255, 0.3) 0%, rgba(97, 160, 255, 0.3) 107.5%);
}
} .con_info {
p {
font-size: 14px;
line-height: 22px;
margin-top: 16px;
color: #1D2128; } img {
width: 100%;
margin-top: 16px;
}
}
}
}
}
} .update_tab {
width: 240px;
padding-top: 16px; /deep/ .updateTab {
.el-tabs__header {
float: left;
text-align: left;
} .el-tabs__nav {
float: none !important;
} .el-tabs__item {
font-size: 14px;
color: #86909C;
} .el-tabs__item.is-active {
color: #2D5CF6;
} .el-tabs__active-bar {
background-color: #2D5CF6;
}
}
}
}
}
}
</style>

vue2实现tabs侧边导航栏点击内容跳转到对应位置,且内容滚动导航栏切换对应tab的更多相关文章

  1. uni-城市列表滑动组件,点击字母跳转到指定位置

    本插件由博主自主开发,比uni插件市场的城市列表滑动组件性能好,且不会出现闪屏的情况. 通过计算城市列表的高度实现滚动到指定位置,使用了uni滚动到指定位置的api city-chooce为页面入口页 ...

  2. ios 导航栏 点击barbutton的按钮 下拉列表

    环境:xocde5.0.2+ios7.0.1 1.导航栏 ----点击科目--------下拉列表 代码:NGRightTableViewViewController.h #import <UI ...

  3. MFC无边框窗体不响应任务栏点击问题

    为了提升用户体验,需要隐藏主窗体的边框,使用图片绘制新的标题栏.标题栏绘制之后,发现用户点击任务栏上应用程序的图标,应用程序不会随着点击交替隐藏显示. 分析结果是问题出现窗体风格设置上. 最初为了省事 ...

  4. 基于sticky组件,实现带sticky效果的tab导航和滚动导航

    上文提供了一个改进版的sticky组件,并将演示效果应用到了自己的博客.有了类似sticky的这种简单组件,我们就可以在利用它开发更丰富的效果,比如本文要介绍的tab导航和滚动导航.实现简单,演示效果 ...

  5. 鼠标移到导航上面 当前的LI变色 处于当前的位置

    鼠标移到导航上面 当前的LI变色 处于当前的位置,广泛应用于当前导航. 点击这里查看效果 以下是源代码: <html> <head> <meta http-equiv=& ...

  6. react-navigation的多次点击重复跳转同一页面、不在堆栈路由页面使用navigation方法的解决思路

    一.react-navigation的初使用 createStackNavigator  ==> createSwitchNavigator  ==>  createAppContaine ...

  7. jquery 滚轴滚动 导航定位和锚点定位

    自己写的,只测试了ie9+, firefox,chrome 以下js更好 var fixbar={ init:function(){ "use strict"; // 滚轴 导航位 ...

  8. 制作四个选项卡页 Tab,用户可以通过切换不同的 Tab 页查看不同类别的新闻信息,每个 Tab 有对应的内容版块,点击某个选项卡时,显示对应的内容版块,隐藏其他内容版块,并且为了突出当前的选项卡,还

    查看本章节 查看作业目录 需求说明: 制作四个选项卡页 Tab,用户可以通过切换不同的 Tab 页查看不同类别的新闻信息,每个 Tab 有对应的内容版块,点击某个选项卡时,显示对应的内容版块,隐藏其他 ...

  9. 使用Android点击按钮跳转页面

    1.首先新建一个Android工程,命名为MyApp(名字可以自己随意起); 2.以原有的MainActivity.java文件为登录界面,然后在src文件中的包上面右击选择New目录下的Other中 ...

  10. 如何绑定android点击事件--跳转到另一个页面并实现关闭功能?

    一.点击按钮跳转到另一个页面. eg:实现从一个页面点击跳转到另一个页面 1.首先在一个布局文件(.XML)中绘画了一个跳转按钮(id为btn1): <Button         androi ...

随机推荐

  1. SpringBoot项目动态定时任务之 ScheduledTaskRegistrar(解决方案一)

    前言 ​ 在做SpringBoot项目的过程中,有时客户会提出按照指定时间执行一次业务的需求. ​ 如果客户需要改动业务的执行时间,即动态地调整定时任务的执行时间,那么可以采用SpringBoot自带 ...

  2. nginx 隐藏 index.php 直接访问

    项目配置文件vhosts加上: if ( !-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } 修改后如图

  3. Pytest插件pytest-order指定用例顺序

    Pytest插件pytest-order指定用例顺序 安装  pip install pytest-order 注意不是pytest-ordering 说起来这里有个故事 关于pytest-order ...

  4. 【读书笔记】JS函数式编程指南

    第一章 海鸥群可以合并和繁育 conjoin breed var result = flock_a.conjoin(flock_c).breed(flock_b).conjoin(flo ck_a.b ...

  5. 深入解读.NET MAUI音乐播放器项目(一):概述与架构

    系列文章将分步解读音乐播放器核心业务及代码: 深入解读.NET MAUI音乐播放器项目(一):概述与架构 深入解读.NET MAUI音乐播放器项目(二):播放内核 深入解读.NET MAUI音乐播放器 ...

  6. python 取整方法

    1.向下取整: int() 2.向上取整:ceil() 使用ceil()方法时需要导入math模块,例如 3.四舍五入:round() 4.分别取 将整数部分和小数部分分别取出,可以使用math模块中 ...

  7. Vue3从基础到精通

    目录 一.Vue3介绍 1. Vue3的变化 2. Vue2和Vue3的不同之处 二.Vue3创建项目 1.用vue-lci创建步骤 2.用vite创建步骤 三.setup函数 四.ref.react ...

  8. 【KAWAKO】TVM-在ubuntu服务器上的安装

    目录 下载源码 安装依赖库 修改config.cmake文件 编译 安装python库 添加tophub 简单验证 官方的安装教程在这里 下载源码 从Download Page中下载下来的源码是0.8 ...

  9. JZOJ 1090. 【SDOI2009】晨跑

    题目 略,luogu上有 解析 一眼费用流 然而怎么建图? 首先我们要挖掘题中的限制条件和性质 一个点只能经过一次 能走的天数最长 满足第二条的条件下走过的路程最短 那么显然是最小费用最大流了 对于后 ...

  10. Shell命令-常用操作

    Shell基础 1 Shell命令的基本格式 基本格式 command [选项] [参数] []表示可选的,也就是可有可无.有些命令不写选项和参数也能执行,有些命令在必要的时候可以附带选项和参数. 短 ...