欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Vue實現(xiàn)Tab選項卡切換

 更新時間:2021年09月07日 15:31:42   作者:wbcra  
這篇文章主要為大家詳細介紹了Vue實現(xiàn)Tab選項卡切換,點擊不同標題顯示對應圖片,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Vue實現(xiàn)Tab選項卡切換的具體代碼,供大家參考,具體內容如下

點擊不同的標題顯示出相應的圖片

代碼如下

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js" type="text/javascript"></script>
</head>
<style>
    *{
        margin: 0px;
        padding: 0px;
    }
    #tab{
        width:420px;
        margin: 20px auto;
        position: relative;
    }
    #tab ul li{
        width: 100px;
        height: 30px;
        border: 1px solid #6699CC;
        float: left;
        list-style: none;
        text-align: center;
        line-height: 30px;
    }
    #tab ul li:first-child{
        border-right: none;
        /* border-radius: 10px 0px 0px 0px; */
    }
    #tab ul li:last-child{
        border-left: none;
        /* border-radius: 0px 10px 0px 0px; */
    }
    #tab ul .active{
        background-color:orange;
        color:white;
    }
    #tab div{
        width: 415px;
        position: absolute;
        top: 32px;
        display: none;
    }
    #tab div img{
        width: 350px;
        /* border-radius:0px 0px 10px 10px; */
    }
    #tab div.current{
        display: block;
    }
 
</style>
<body>
    <div id="tab">
            <ul>
                <li v-on:mouseover="change(index)" :class="[currentindex==index?'active':'']":key="item.id"v-for="(item,index) in list">{{item.text}}</li>
            </ul>
            <div :class="[currentindex==index?'current':'']" v-for="(item,index) in list">
                <img :key="item.id" v-bind:src="item.imgsrc"/>
            </div>
    </div>
    
    
</body>
<script type="text/javascript">
    var vm = new Vue({
        el:'#tab',
        data:{
            currentindex:'0',//當前選項卡的索引
             list:[{
                id:'1',
                text:'apple',
                imgsrc:'imgs/1.jpg'
            },{
                id:'2',
                text:'orange',
                imgsrc:'imgs/2.jpg'
            },{
                id:'3',
                text:'lemon',
                imgsrc:'imgs/3.jpg'
            }]
            },
            methods:{
                change:function(index){
                this.currentindex=index;
                     }
            }
            });
</script>
</html>

效果圖

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論