vue实现鼠标滑动展示tab栏切换
作者:逆风优雅 时间:2023-07-02 16:38:05
本文实例为大家分享了vue实现鼠标滑动展示tab栏切换的具体代码,供大家参考,具体内容如下
动画效果:
代码如下:
<template>
<div id="header">
<div class="conten_width">
<div class="contnet_width_content">
<div style=" transform: translateX(-242px);" >
<img src="./../../assets/img/logo.png" alt="" />
</div>
<ul class="header_ul">
<li
v-for="(v, i) in liList"
:key="i"
:class="{ chosed: active === i }"
@mouseover="mouserOver(i, v.type)"
>
{{ v.title }} <a-icon v-if="v.show" :type="v.img" />
</li>
</ul>
<div v-if="dropDownActive==='text1'|| dropDownActive ==='text2'" class="dropDownContent" @mouseleave="contentmouseleave">
<div v-if="active===0" @mousemove="productContentMouseover('text1')" class="porductContentStyle">产品</div>
<div v-if="active===1" @mousemove="planContentMouseover('text2')" class="planContentStyle">解决方案</div>
</div>
<a-input-search
placeholder="input search text"
class="header_input"
@search="onSearch"
/>
<span class="header_right1">文档</span>
<span class="header_right2">控制台</span>
</div>
</div>
</div>
</template>
<script>
export default {
name: "homeLayoutHeader",
data() {
return {
liList: [
{
type: "text1",
title: "产品",
img: "down",
show: true,
},
{
type: "text2",
title: "解决方案",
img: "down",
show: true,
},
{
type: "text3",
title: "支持与服务",
show: false,
},
{
type: "text4",
title: "了解我们",
show: false,
},
],
dropDownActive:'',
active: 0,
};
},
methods: {
mouserOver(v, tp) {
//鼠标移动上去的事件
this.dropDownActive = tp
this.active
this.active = v;
this.liList.map((item, index) => {
if (v === index) {
item.img = "up";
} else {
item.img = "down";
}
});
},
contentmouseleave(){
// 鼠标离开下拉内容区的操作
this.dropDownActive = ''
this.liList.map(item=>{
item.img = 'down'
})
},
productContentMouseover(value){
// 鼠标在产品下面内容区的操作
this.dropDownActive = value
},
planContentMouseover(value){
// 鼠标在解决方案下面内容区的操作
this.dropDownActive = value
},
onSearch() {
console.log(12);
},
},
};
</script>
<style scoped>
* {
margin: 0;
padding: 0;
}
.conten_width {
height: 62px;
width: 1200px;
margin: 0 auto;
box-sizing: border-box;
}
.contnet_width_content {
height: 62px;
width: 1200px;
display: flex;
justify-content: center;
align-items: center;
}
.header_ul {
display: flex;
width: 340px;
height: 14px;
justify-content: space-between;
transform: translateX(-169px);
}
.header_ul li {
padding-bottom: 36px;
cursor: pointer;
}
.header_input {
width: 200px;
transform: translateX(170px);
}
.header_right1 {
transform: translateX(210px);
}
.header_right2{
transform: translateX(240px);
}
.chosed {
border-bottom: 2px solid red;
}
.dropDownContent {
/* margin: 0 auto; */
position: absolute;
z-index: 6;
top: 63px;
}
.porductContentStyle{
width: 1000px;
height: 300px;
background: red;
}
.planContentStyle{
width: 800px;
height: 300px;
background: green;
}
</style>
来源:https://blog.csdn.net/qq_44603011/article/details/122473096
标签:vue,滑动,切换
0
投稿
猜你喜欢
Javascript的一种模块模式
2007-12-05 14:04:00
Python爬虫定时计划任务的几种常见方法(推荐)
2021-06-02 02:05:39
jquery模拟SELECT下拉框取值效果
2024-04-22 12:58:56
Python制作微信机器人教程详解
2021-05-09 13:44:44
selenium python浏览器多窗口处理代码示例
2023-11-20 07:09:29
pytorch 输出中间层特征的实例
2022-06-08 07:36:39
asp加载access数据库并生成XML文件范例
2008-07-22 12:41:00
python中将正则过滤的内容输出写入到文件中的实例
2023-12-15 06:56:09
新建文件时Pycharm中自动设置头部模板信息的方法
2021-08-18 11:56:46
Python使用Matplotlib实现Logos设计代码
2021-02-04 19:18:34
Python中Continue语句的用法的举例详解
2023-04-04 13:12:37
详解Python3中的 input() 函数
2022-09-21 19:50:59
Python tkinter 树形列表控件(Treeview)的使用方法
2023-10-06 23:14:47
简单代码实现可输入的下拉框功能(select)
2008-10-20 19:52:00
PYQT5 实现给listwidget的滚动条添加滚动信号
2023-06-07 00:19:01
python 第三方库的安装及pip的使用详解
2023-12-27 07:06:53
golang之数据验证validator的实现
2024-04-26 17:36:03
深入理解MySQL事务的4种隔离级别
2024-01-21 09:52:40
如何用ASP发送HTML格式的邮件?
2010-06-11 19:41:00
TensorFlow安装并在Pycharm搭建环境的详细图文教程
2023-09-12 16:34:00