• tab


    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
            <style>
                .tab{
                    width: 500px;
                    background: #fff;
                    margin: 0 auto;
                    background: rgb(227,232,238);
                    padding: 16px;
                }
                .tab-header{
                    overflow: hidden;
                }
                .tab-item{
                    width: 100px;
                    height: 30px;
                    line-height: 30px;
                    background: #ccc;
                    border: 1px solid #dddee1;
                    background: #f8f8f9;
                    text-align: center;
                    margin-right: 5px;
                    border-radius: 2px;
                    float: left;
                }
                .tab-active{
                    border-color: transparent;
                    height: 32px;
                    margin-bottom: 5px;
                    background: #fff;
                    transform: translateZ(0);
                    color: #e6451e;
                }
                .tab-content{
                    height: 100px;
                    line-height: 10px;
                    background: #fff;
                    overflow: hidden;
                }
                .tab-content div{
                    width: 100%;
                    height: 100%;
                    text-align: center;
                    display: none;
                }
            </style>
        </head>
        <body>
            <div class="tab" id="app">
                <div class="tab-header">
                    <div 
                        v-for="item ,index in tabData" 
                        class="tab-item"
                        @click="tab(index)"
                        v-bind:class="{'tab-active':index===currentIndex}"
                        >
                    {{item.title}}
                    </div>
                    
                </div>
                <div class="tab-content">
                    <div 
                        v-for="item,index in tabData" 
                        v-bind:style="{display: index===currentIndex?'block':'none'}"
                    >
                        <p v-for="option in item.list">{{option.subTitle}}</p>
                    </div>
                    
                </div>
            </div>
        </body>
        <script>
            let tabData=[
                {
                    title:'标签一123',
                    list:[
                        {
                            subTitle:'css课程'
                        },
                        {
                            subTitle:'css课程'
                        },
                        {
                            subTitle:'css课程'
                        }
                    ]
                },
                {
                    title:'标签二456',
                    list:[
                        {
                            subTitle:'js课程'
                        }
                    ]
                },
                {
                    title:'标签三789',
                    list:[
                        {
                            subTitle:'Vue课程'
                        }
                    ]
                }
            ]
            new Vue({
                el:"#app",
                data:{
                    tabData:tabData,
                    currentIndex:1
                },
                methods:{
                    tab(index){
                        this.currentIndex=index;
                    }
                }
            })
        </script>
    </html>

  • 相关阅读:
    解决secureCRT数据库里没有找到防火墙 '无'问题
    关于mysql中int(1)中int后面的数字
    Mac下安装LNMP(Nginx+PHP5.6)环境
    MAC: Homebrew(代替yum)安装
    Mac下面的SecureCRT(附破解方案) 更新到最新的8.0.2
    如何在Macbook Pro搭建PHP开发环境
    MetaMask/metamask-inpage-provider
    MetaMask/safe-event-emitter
    mafintosh/end-of-stream
    MetaMask/sw-controller
  • 原文地址:https://www.cnblogs.com/gxywb/p/10681656.html
Copyright © 2020-2023  润新知