problem description
see the following figure.
check to change the color, up to 7. There will be a prompt after clicking on the 8th. And more than 7 clicks do not change the color.
if I click on the previously selected color, I can remove the selected color, and I can also click on something else that is not selected.
the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)
<view class="habit_taglist">
<view class="{{item.active?"active-tag":""}} habit_tag fl" wx:for="{{tags}}" bindtap="tagTap" data-key="{{index}}" wx:key="index" data-test="4">{{item.habitName}}</view>
< / view >
tagTap: function (e) {
this.setData({
habittags: []
})
var index = e.currentTarget.dataset.key;
console.log(this.data.tags)
for (var i = 0; i < this.data.tags.length; iPP) {
if (this.data.tags[i].active) {
this.data.habittags.push(
{
habitId: this.data.tags[i].zid,
babyId: this.data.babyId,
groupId: getApp().globalData.groupId,
habitDay: this.data.tags[i].habitDay
})
}
}
this.setData({
habittags: this.data.habittags
})
console.log(this.data.habittags)
if (this.data.habittags.length >= 7) {
if (this.data.tags[index].active) {
this.data.tags[index].active = !this.data.tags[index].active
this.setData({
tags: this.data.tags
});
} else {
var test = e.target.dataset.test;
if (test == 4) {
getApp().feedbackApi.showToast({
title: "7",
mask: false
})
}
}
} else {
this.data.tags[index].active = !this.data.tags[index].active
this.setData({
tags: this.data.tags
});
}
},
what result do you expect? What is the error message actually seen?
the above has bug for advice