第一部分
<template>
<!-- 搜索框 -->
<YgSearch/>
<!-- tabs 标签页 -->
<u-tabs :list="tabsList" :current="current" :is-scroll="false" @change="changeTab"/>
<!-- <u-tabs :list="tabsList" :current="current" :is-scroll="false" @change="changeTab"/> -->
<Tabs/>
</view>
</template>
<script>
import Tabs from "./components/tabs.vue";
export default {
components: { Tabs },
data() {
return {
tabsList: [],
};
},
};
第2部分
<template>
<view class="list">
<view class="item"
:class="{active: index === current}"
v-for="(item, index) in list"
:key="index"
@click="changeTab(index)"
>
{{item}}
</view>
<view class="underline" :class="{
left: current === 0,
middle: current === 1,
right: current === 2
}"></view>
</view>
</template>
<script>
export default {
data() {
return {
current: 0,
list: ['综合', '销量', '价格']
}
},
methods: {
changeTab(index) {
console.log(index);
this.current = index
}
}
}
</script>
<style lang="scss" scoped>
.list {
display: flex;
position: relative;
.item {
width: 33.33%;
text-align: center;
font-size: 30rpx;
line-height: 88rpx;
color: #676767;
}
.active {
color: #eb4450;
font-weight: bold;
}
.underline {
width: 25.33%;
margin: 0 4%;
height: 6rpx;
background-color: #eb4450;
position: absolute;
bottom: 0;
left: 0;
transition: all 0.5s;
&.middle {
left: 33.33%;
}
&.right {
left: 66.66%;
}
}
}