WeChat Mini Programs selected, if the click is not the selected 7, more than 7 prompts more than 7, if you click on the selected 7 to reduce the selected, selected to change the color

problem description

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) {
    var index = e.currentTarget.dataset.key;
    this.data.tags[index].active = !this.data.tags[index].active
    this.setData({
      tags: this.data.tags
    });
    console.log(this.data.tags)
 },

what result do you expect? What is the error message actually seen?


ask for advice

Dec.14,2021

resolved.
tagTap:

function (e) {
    this.setData({
      habittags:[]
    })
    var index = e.currentTarget.dataset.key;
    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
    })
    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) {
          feedbackApi.showToast({
            title: '7',
            mask: false
          })
        }
      }
    }else{
      this.data.tags[index].active = !this.data.tags[index].active
      this.setData({
        tags: this.data.tags
      });
    }    

},

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e44719-44240.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e44719-44240.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?