Vue.js implements tab switching and color change operation explanation

Vue.js implements tab switching and color change operation explanation

When implementing this function, the method I borrowed from the original blogger did not achieve the color switching. After thinking about it for a long time, I finally figured out how to switch the color (the roar of a rookie)! ! ! Recorded for reference, the following is the code framework for Vue's complete tab page switching and color change.

<template>
<div >
     //tab page switch button part <ul>
        <li v-for="(item,index) in navList" :class = "{active:!(index- 
            menuIndex)}" @click = 'menuShow(index)'>
          <a href="#" rel="external nofollow" >{{item}}</a>
        </li>
      </ul>
 
   //Content body <div v-show = 'menuIndex == 0'> Content 1 <!-- This can be replaced with a subcomponent--></div>
   <div v-show = 'menuIndex == 1'>Content 2<!--You can replace it with a subcomponent here--></div>
</div>
</template>
 
<script type="text/javascript">
export default {
data(){
      return {
         menuIndex:0,
        navList:['Middleware Details', 'Deployment Architecture'],
      }
            }
   methods: {
      menuShow (index) {
        this.menuIndex = index
        console.log(this.menuIndex)
      }
}
</script>
//Style <style scoped>
//Click to switch the color, I set it to blue.active{
    background-color: rgba(13, 175, 255, 0.33);
    }
<style>

Switch color is this

.active{
//background color background-color: rgba(13, 175, 255, 0.33);
//font color: red;
  }

The following is the effect diagram:

Click on the middleware details:

Effect picture:

Click to deploy the architecture:

This is the end of this article about Vue.js implementing tab switching and color change operations. For more related Vue.js implementing tab switching and color change content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Vue implements the color change function of clicking the current tab in the navigation bar
  • Vant solves the problem of customizing the title style of the tab switching plug-in
  • Example of tab switching effect implemented by Vue2.0 (content can be customized)
  • How to change label color of vant tab in vue project

<<:  How does MySQL ensure data integrity?

>>:  Detailed tutorial on downloading, installing and configuring the latest version of MySQL 8.0.21

Recommend

Docker+nacos+seata1.3.0 installation and usage configuration tutorial

I spent a day on it before this. Although Seata i...

Web developers are concerned about the coexistence of IE7 and IE8

I installed IE8 today. When I went to the Microso...

Implementation of scheduled backup in Mysql5.7

1. Find mysqldump.exe in the MySQL installation p...

Analysis of the Docker deployment Consul configuration process

Execute Command docker run -d --name consul -p 85...

Three ways to copy MySQL tables (summary)

Copy table structure and its data The following s...

Why is the scroll bar on the web page set on the right?

Why are the scroll bars of the browsers and word ...

Learn MySQL database in one hour (Zhang Guo)

Table of contents 1. Database Overview 1.1 Develo...

Analysis of Context application scenarios in React

Context definition and purpose Context provides a...

Solution to mysql failure to start due to insufficient disk space in ubuntu

Preface Recently, I added two fields to a table i...

HTML Tutorial: Collection of commonly used HTML tags (6)

These introduced HTML tags do not necessarily ful...

Linux View File System Type Example Method

How to check the file system type of a partition ...

How to add website icon?

The first step is to prepare an icon making softwa...

Example of how to implement value transfer between WeChat mini program pages

Passing values ​​between mini program pages Good ...

The difference between clientWidth, offsetWidth, scrollWidth in JavaScript

1. Concept They are all attributes of Element, in...

Tutorial on installing php5, uninstalling php, and installing php7 on centos

First, install PHP5 very simple yum install php T...