Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vue] 30. v-for 产生的列表,实现 active 的切换 #421

Open
qiilee opened this issue Oct 8, 2019 · 1 comment
Open

[vue] 30. v-for 产生的列表,实现 active 的切换 #421

qiilee opened this issue Oct 8, 2019 · 1 comment
Labels

Comments

@qiilee
Copy link
Member

qiilee commented Oct 8, 2019

No description provided.

@qiilee qiilee added the VUE label Oct 8, 2019
@qinjr163
Copy link

1、点击时传入index索引(获取当前点击的是哪个)
@click="active(index)"

2、将索引值传入class(索引等于几就第几个添加active类)
:class="{active:index==ins}"

3、在data里边添加ins:0(表示默认第一个添加active类)
data{ ins:0 } 

4、最后在methods里边添加方法
active(num) {
       this.ins=num
}
原文链接:https://blog.csdn.net/qq_38543537/article/details/79142578

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants