2023.11.7
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
:class="{current: index === tabCurrentIndex}" :id="'tab'+index" @click="changeTab(index)">{{item.name}}
|
||||
</view> -->
|
||||
<view v-for="(item,index) in tabArr" :key="item.id" class="nav-item"
|
||||
:style="{width:tab_width+'%'}"
|
||||
:class="{current: index === o_index}" :id="'tab'+index" @click="changeTab(index)">{{item.name}}
|
||||
</view>
|
||||
</scroll-view>
|
||||
@@ -22,16 +23,18 @@
|
||||
scrollTimer = false,
|
||||
tabBar;
|
||||
export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
tabCurrentIndex: 0, //当前选项卡索引
|
||||
scrollLeft: 0, //顶部选项卡左滑距离
|
||||
|
||||
tab_width:0,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log(this.tabArr)
|
||||
this.tab_width = parseFloat(100/this.tabArr.length)
|
||||
},
|
||||
props: {
|
||||
|
||||
tabArr: {
|
||||
type: Array,
|
||||
default () {
|
||||
@@ -47,7 +50,6 @@
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
//tab切换
|
||||
async changeTab(e) {
|
||||
|
||||
@@ -160,14 +162,15 @@
|
||||
.nav-item {
|
||||
display: inline-block;
|
||||
/* width: 150upx; */
|
||||
width: 50%;
|
||||
/* width: 33.33%; */
|
||||
height: 90upx;
|
||||
text-align: center;
|
||||
line-height: 90upx;
|
||||
font-size: 30upx;
|
||||
color: #303133;
|
||||
/* color: #303133; */
|
||||
color: gray;
|
||||
position: relative;
|
||||
|
||||
font-weight: 900;
|
||||
&:after {
|
||||
content: '';
|
||||
width: 0;
|
||||
|
Reference in New Issue
Block a user