Vue implements Tab tab switching

Vue implements Tab tab switching

This article example shares the specific code of Vue to implement Tab tab switching for your reference. The specific content is as follows

Click on different titles to display the corresponding pictures

The code is as follows

<!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', //The index of the current tab 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>

Rendering

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Vue.js implements tab switching
  • Vue tab switching login method small case
  • Vue.js components implement tabs and switching effects
  • Vue realizes the effect of tabs and tab switching
  • Vue.js tab realizes tab switching
  • Using dynamic components to achieve tab switching effect in Vue
  • Vue dynamic component to achieve tab switching effect
  • Vue.js component tab implements tab switching
  • Vue.js component tabs to achieve tab switching effect
  • Vue implements tab switching

<<:  Detailed explanation of how to deploy programs on Alibaba Cloud Server and access them directly using domain names

>>:  MySQL Best Practices: Basic Types of Partition Tables

Recommend

Mysql 5.7.19 free installation version encountered pitfalls (collection)

1. Download the 64-bit zip file from the official...

Convert XHTML CSS pages to printer pages

In the past, creating a printer-friendly version ...

Design Theory: A Method to Understand People's Hearts

<br />Once, Foyin and Mr. Dongpo were chatti...

Complete steps to enable gzip compression in nginx

Table of contents Preface 1. Configure gzip compr...

How to use less in WeChat applet (optimal method)

Preface I am used to writing less/sass, but now I...

Detailed description of component-based front-end development process

Background <br />Students who work on the fr...

MySQL 8.0.16 installation and configuration tutorial under Windows 10

This article shares with you the graphic tutorial...

Detailed explanation of Tomcat directory structure

Table of contents Directory Structure bin directo...

Supplementary article on front-end performance optimization

Preface I looked at the previously published arti...

Baidu Input Method opens API, claims it can be ported and used at will

The relevant person in charge of Baidu Input Metho...