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:
|
<<: How does MySQL ensure data integrity?
>>: Detailed tutorial on downloading, installing and configuring the latest version of MySQL 8.0.21
I spent a day on it before this. Although Seata i...
I installed IE8 today. When I went to the Microso...
1. Find mysqldump.exe in the MySQL installation p...
Execute Command docker run -d --name consul -p 85...
Copy table structure and its data The following s...
Why are the scroll bars of the browsers and word ...
Table of contents 1. Database Overview 1.1 Develo...
Context definition and purpose Context provides a...
Preface Recently, I added two fields to a table i...
These introduced HTML tags do not necessarily ful...
How to check the file system type of a partition ...
The first step is to prepare an icon making softwa...
Passing values between mini program pages Good ...
1. Concept They are all attributes of Element, in...
First, install PHP5 very simple yum install php T...