Vue pure front end how to store the selected status of coupons to display

Page A Click function A jumps to page B to select coupons. Either single or multiple selections can be saved and then go back to page A
and then click on page A to select coupons from page B.
P.S saves the coupons that have been selected before

how to implement pure front-end vue

coupon structure code

 <el-col :span="3" v-for="item in tableData" class="item" :key="item.id">
        <div @click="handleItemClick(item)">
          <div class="selected" v-if="item.isSelected"></div>
          <div class="header">{{item.name}}</div>
          <div class="left-circle"></div>
          <div class="left"></div>
          <div class="middle">
            <div class="price text" v-if="item.groupGoodsVO">{{item.groupGoodsVO.goodsName}}</div>
            <div class="price" v-else>
              <span></span>{{item.price | money}}
            </div>
            <div class="condition">
              {{item.money === -1 ? "" : `${(item.money / 100).toFixed(0)}`}}
            </div>
            <div class="date">
              {{getValidDate(item)}}
            </div>
          </div>
          <div class="right-circle"></div>
          <div class="right"></div>
          <div class="bottom">
            <div class="bottom-text">
              <span class="label">:</span>
              <span class="value">{{item.groupRuleGoodsVO ? "" : ""}}</span>
              <span class="label">:</span>
              <span class="value">{{item.groupRuleGoodsVO ? "" : ""}}</span>
              <span class="label">:</span>
              <span class="value">{{item.codeRule}}</span>
            </div>
            <!--<div>-->
              <!--<span class="label">:</span>-->
              <!--<span class="value">{{item.groupRuleScopeVO ? "" : ""}}</span>-->
            <!--</div>-->
            <!--<div>-->
              <!--<span class="label">:</span>-->
              <!--<span class="value">{{item.codeRule}}</span>-->
            <!--</div>-->
          </div>
        </div>
      </el-col>

Select the coupon function code

 handleItemClick (item) {
        console.log(item);
        this.tableData.map((data) => { 
          if (item.id === data.id) {
            // this.$set(data, "isSelected", item.id === data.id);
            if (item.isSelected){
              this.$set(data, "isSelected",false);
            } else {
              this.$set(data, "isSelected",true);
            };
          }
        });
      }
Feb.27,2021

use vuex. Define a variable m in state to store the logo of the currently selected item, and write an a method to store it in mutation. At each click to open the selection, make a match between the m of the getter and all the current selections to see if the flag exists in the variable and then the corresponding display. Then when you finish selecting the submission, call method a with the checked item corresponding flag commit, and re-store the update flag output m.


means that you need an operation to save data

you can use local storage localstorage cookie

or vuex

or url pass parameters

there are many ways, according to your needs


it's not clear what you mean by pure front end. If it's a spa application, just use vuex to save it globally. If it is a web page, you can use some local save features of the web page.

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-1eac2a3-20b3.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-1eac2a3-20b3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?