【发布时间】:2021-05-31 17:31:36
【问题描述】:
我有一系列带有关注、取消关注状态的按钮,当我点击每个按钮时,我希望它的状态在一点延迟和停用后改变,并且按钮被重新激活,例如,如果按钮在关注模式,当被点击时,按钮将被停用并加载,直到执行了后端操作然后将其状态更改为取消关注。 但是现在只需单击一个按钮,所有按钮就会一起改变位置。
我的工作成果如下图:
我在用户端写的代码如下:
<v-btn
@click="join()"
:loading="joinGroup"
:disabled="joinGroup"
dark
v-show="joinBtn"
color="#7256EA"
class="mt-2 rounded-full bg-purple-gradient"
>Join Group
</v-btn>
我在后面写的代码如下:
<script>
data() {
return {
joinGroup: false,
}
}
methods: {
join: async function() {
this.joinGroup = true;
if (
this.group.privacy == 1 ||
(this.group.privacy == 2 && this.isFollower)
) {
this.addGroupMember(true);
} else if (this.group.privacy == 0) {
await this.addGroupMember(false);
this.sendJoinRequest();
this.snackBarPrivate();
} else if (this.group.privacy == 2 && !this.isFollower) {
this.snackBarFollowers();
}
this.joinGroup = false;
},
}
</script>
【问题讨论】:
-
您的所有按钮都使用了
:loading="joinGroup"吗?
标签: javascript html vue.js nuxt.js vuetify.js