标签:vue .. 100% height width 切换 tab image png
如图所示
<template>
<div class="home" @touchmove.prevent @mousewheel.prevent>
<div class="header">
<div class="header-one">
<div></div>
</div>
<div class="header-two">
<van-search
clearable="true"
shape="round"
background="#ffff"
maxlength="10"
v-model="value"
placeholder="请输入搜索关键词"
input-align="center"
/>
</div>
</div>
<div class="sec">
<ul class="topnav-show" v-show="currindex==0">
<li>内容1</li>
</ul>
<ul class="topnav-show" v-show="currindex==1">
<li>内容2</li>
</ul>
<ul class="topnav-show" v-show="currindex==2">
<li>内容3</li>
</ul>
<ul class="topnav-show" v-show="currindex==3">
<li>内容4</li>
</ul>
</div>
<div class="footer">
<ul>
<!-- vue实现tab切换并带切换样式的效果 -->
<li v-for="(item,index) in tabList" :key="index" @click="btncli(index)">
<P class="produc">
<img :src="currindex==index ?item.img1 :item.img" alt />
</P>
<!-- <P :class="{text:!(index-currindex)}">{{item.name}}</P>
这个也是切换的效果 -->
<P :class="currindex==index?'text':''">{{item.name}}</P>
</li>
</ul>
</div>
</div>
</template>
<script>
export default {
name: "Home",
data() {
return {
value: "", //这个是搜索的value值
currindex: 0, //默认显示索引0
tabList: [
{
name: "产品",
img: require("../../src/assets/image/icon_product@3x(2).png"),
img1: require("../../src/assets/image/icon_product@3x.png")
},
{
name: "任务",
img: require("../../src/assets/image/icon_product@3x(1).png"),
img1: require("../../src/assets/image/icon_product@3x1(1).png")
},
{
name: "问答",
img: require("../../src/assets/image/icon_product@3x(2).png"),
img1: require("../../src/assets/image/icon_product@33x.png")
},
{
name: "我的",
img: require("../../src/assets/image/icon_product@3x(3).png"),
img1: require("../../src/assets/image/icon_product@32x.png")
}
]
};
},
methods: {
// 点击切换tab
btncli(index) {
this.currindex = index;
},
onSearch(val) {
Toast(val);
},
onCancel() {
Toast("取消");
}
},
components: {}
};
</script>
<style lang="scss" scoped>
.home {
width: 100%;
height: 100vh;
.header {
width: 100%;
height: 100px;
line-height: 100px;
vertical-align: middle;
display: flex;
/deep/.header-one {
flex: 1.5;
padding: 26px;
vertical-align: middle;
div {
width: 100px;
height: 50px;
background: url("../assets/image/button_screen@3x.png") no-repeat center;
background-size: cover;
background-size: 100% 100%; //等比例拉伸
}
}
.header-two {
flex: 7;
/deep/.van-search__content--round {
border: 1px solid rgb(233, 229, 229);
}
/deep/.van-field__control {
width: 70%;
}
/deep/.van-icon {
font-size: 36px;
line-height: 60px;
}
/deep/.van-search {
width: 90%;
height: 100px;
.van-cell {
background: none;
}
.van-cell__value {
height: 60px;
line-height: 60px;
font-size: 26px;
color: black !important;
}
}
}
}
.sec {
width: 100%;
height: calc(100% - 210px);
border: 1px solid red;
}
.footer {
width: 100%;
height: 110px;
border: 1px solid red;
ul {
display: flex;
line-height: 80px;
font-size: 30px;
color: #999999;
justify-content: space-around;
.text {
color: #8dd966;
}
.produc {
width: 60px;
height: 50px;
vertical-align: middle;
margin-bottom: -16px;
margin-top: 12px;
border: 1px solid red;
img {
width: 100%;
height: 100%;
}
}
}
}
}
</style>
标签:vue,..,100%,height,width,切换,tab,image,png 来源: https://blog.csdn.net/m0_53912016/article/details/121028078
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。