一、效果图
二、代码
<template>
<view>
<view class="choose-tab">
<view class="choose-tab-item" :class="chooseTab == 0 ? 'active' : ''" data-choose="0" @click="clickTab">选项1view>
<view class="choose-tab-item" :class="chooseTab == 1 ? 'active' : ''" data-choose="1" @click="clickTab">选项2view>
<view class="choose-tab-item" :class="chooseTab == 2 ? 'active' : ''" data-choose="2" @click="clickTab">选项3view>
<view class="choose-tab-item" :class="chooseTab == 3 ? 'active' : ''" data-choose="3" @click="clickTab">选项4view>
view>
<view class="content">
<view :style="chooseTab != 0 ? 'display:none' : ''">选项1内容view>
<view :style="chooseTab != 1 ? 'display:none' : ''">二内容view>
<view :style="chooseTab != 2 ? 'display:none' : ''">three contentview>
<view :style="chooseTab != 3 ? 'display:none' : ''">1+1+1+1=4view>
view>
view>
template>
<script>
export default {
data() {
return {
chooseTab: 0
}
},
onLoad: function (options) {
},
methods: {
clickTab: function (e) {
this.chooseTab = e.target.dataset.choose;
}
}
}
script>
<style>
.choose-tab {
display: flex;
flex-flow: row;
justify-content: space-between;
width: 100%;
height: 90rpx;
line-height: 90rpx;
text-align: center;
border-bottom: 2rpx solid #ccc;
}
.choose-tab-item {
width: 25%;
}
.active {
color: red;
border-bottom: 4rpx solid red;
}
.content {
text-align: center;
}
style>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
转载大佬