2022-02-18 默认展示的是第一个

<!-- 派驻发现问题 -->

<template>

    <div>

        <div class="btnTitle">

            <div class="btn-bg" :class="{bg:time == 3}" @click="changeBg(3)">15天</div>

            <div class="btn-bg" :class="{bg:time == 4}" @click="changeBg(4)">30天</div>

        </div>

        <div class="btnTitle">

            <div class="btn-bg" :class="{bg:increase == 5}" @click="changeBg(5)">增量</div>

            <div class="btn-bg" :class="{bg:increase == 6}" @click="changeBg(6)">总量</div>

        </div>

    </div>

</template>

<script>

    export default {

        data() {

            return {

                time: 3,

                increase: 5,

            };

        },

        methods: {

            changeBg(index) {

                if (index === 3 || index === 4) {

                    this.time = index

                } else if (index === 5 || index === 6) {

                    this.increase = index

                } else {

                    this.sort = index

                }

            }

        }

    }

</script>

<style scoped>

    .bg {

        background-color: rgb(12, 197, 89);

        color: #fff;

    }

    .btnTitle {

        display: flex;

        width: 400px;

        border: 1px solid #ccc;

        background-color: #fff;

        margin-left: 10px;

        border-radius: 5px;

    }

    .btnTitle>.btn-bg {

        width: 50%;

        height: 40px;

        text-align: center;

        line-height: 40px;

        border-radius: 5px;

    }

</style>


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容