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

Introduction to the B-Tree Insertion Process

In the previous article https://www.jb51.net/arti...

CUDA8.0 and CUDA9.0 coexist under Ubuntu16.04

Preface Some of the earlier codes on Github may r...

How to install and configure GitLab on Ubuntu 20.04

introduce GitLab CE or Community Edition is an op...

XHTML Getting Started Tutorial: Form Tags

<br />Forms are an important channel for use...

Use Navicate to connect to MySQL on Alibaba Cloud Server

1. First enter the server's mysql to modify p...

Three ways to prevent MySQL from inserting duplicate data

Create a new table CREATE TABLE `person` ( `id` i...

Transplanting the mkfs.vfat command in busybox under Linux system

In order to extend the disk life for storing audi...

W3C Tutorial (10): W3C XQuery Activities

XQuery is a language for extracting data from XML...

Problems encountered in the execution order of AND and OR in SQL statements

question I encountered a problem when writing dat...

Regular expression usage in CSS selectors

Yes, CSS has regular expressions too (Amen) Two p...