Vue implements active click switching method
May 29, 2018 pm 05:43 PMBelow I will share with you an article on how to implement active click switching in Vue. It has a good reference value and I hope it will be helpful to everyone.
Loop situation:
1. Pass in the index when clicking (get which one is currently clicked)
1 |
|
2. Pass the index value into the class (add the active class according to the index value)
1 |
|
3. Add ins in data: 0 (meaning the active class is added first by default)
1 |
|
#4. Finally, add methods in methods
1 2 3 |
|
Non-cyclic situation:
1. Write the click event and Added class style
Notes: :class="{active:shows==1}" means that class=active is added when shows==1, otherwise it is not added. .
2. Define the method in methods
The effect is as follows:
That’s it. Click to switch the effect.
Additional:
Use the three-wood operator to implement filter arrow switching
Above I compiled it for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Detailed explanation of VUE’s extension of ElTableColumn in element-ui
Javascript performance optimization time-sharing function Introduction
Detailed explanation of Vue custom dynamic component instances
The above is the detailed content of Vue implements active click switching method. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to write a novel in the Tomato Free Novel app. Share the tutorial on how to write a novel in Tomato Novel.

How to enter bios on Colorful motherboard? Teach you two methods

How to recover deleted contacts on WeChat (simple tutorial tells you how to recover deleted contacts)

Summary of methods to obtain administrator rights in Win11

Quickly master: How to open two WeChat accounts on Huawei mobile phones revealed!

The secret of hatching mobile dragon eggs is revealed (step by step to teach you how to successfully hatch mobile dragon eggs)

Detailed explanation of Oracle version query method

How to set font size on mobile phone (easily adjust font size on mobile phone)
