四个分段器

<template>
    <view>
        <view class="uni-padding-wrap uni-common-mt " v-show="flag">
            <uni-segmented-control :current="current1" :values="lists" @clickItem="onClickItem1"  :styleType="styleType"
                :activeColor="activeColor"></uni-segmented-control>
        </view>

        <view>
            <input type="text" placeholder="搜索" v-show="!flag">
        </view>

        <view class="uni-padding-wrap uni-common-mt uni-bottom" >
            <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" :styleType="styleType"
                :activeColor="activeColor"></uni-segmented-control>
        </view>

        <view class="content">
            <view>
                <view v-show="typeChannel === 0">
                    选项卡1的内容
                </view>
               <view v-show="typeChannel === 1">
                    选项卡2的内容
                </view>
                <view v-show="typeChannel === 2">
                    选项卡3的内容
                </view>
                <view v-show="typeChannel === 3">
                    选项卡4的内容
                </view>
            </view>
        </view>


    </view>
</template>

<script>
    import uniSegmentedControl from '../../components/uni-segmented-control.vue';

    export default {
        data() {
            return {
                flag: false,
                items: [
                    '选项卡1',
                    '选项卡2',

                ],
                lists: [
                    '选项卡3',
                    '选项卡4'

                ],
                styles: [{
                    value: 'button',
                    text: '按钮'
                }, {
                    value: 'text',
                    text: '文字'
                }],
                colors: [
                    '#007aff',
                    '#4cd964',
                    '#dd524d'
                ],
                current: 0,
                current1 : 0,
                typeChannel: 0,
                activeColor: '#007aff',
                styleType: 'button',
                styleIndex: 0,
                colorIndex: 0,
            }
        },
        components: {
            uniSegmentedControl
        },
        methods: {
          
            onClickItem(index) {
                console.log(index)
                this.flag = !this.flag
                this.typeChannel = index;
            },
            onClickItem1(index) {
                console.log(index)
                this.current1 = index;
                this.typeChannel = 2+index;
            },
            styleChange(evt) {
                const value = evt.target.value;
                if (this.styleType !== value) {
                    this.styleType = value;
                    for (let i = 0; i < this.styles.length; i++) {
                        if (this.styles[i].value === value) {
                            this.styleIndex = i;
                            break;
                        }
                    }
                }
            },
            colorChange(evt) {
                if (this.styleType !== evt.target.value) {
                    this.activeColor = evt.target.value;
                    this.colorIndex = this.colors.indexOf(evt.target.value);
                }
            }
        }
    }
</script>

<style>
    page {
        height: auto;
    }

    .uni-bottom {
        margin-top: 200upx;
    }

    .content {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 300upx;
        text-align: center;
    }

    .color-tag {
        width: 50upx;
        height: 50upx;
    }
</style>
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值