How do I save the selected state of checkbox?

clipboard.png

after jumping to the order page, click to return to the current page, but can not keep the item selected, how to solve?

 <template>
      <div>
        <ul>
            <li class="bookItem" v-for="item in bookList" :key="item.id" style="text-align: left;">
                <el-checkbox-group v-model="checkList" @change="handleCheckedBooks">
                    <el-checkbox :label="item.id">
                        <img class="bookImg" :src="item.book_url" style="width: 100px; height: 100px;">
                        <h3>{{item.book_title}}</h3>
                        <span class="price">{{item.book_price}}</span>
                        <div>
                            <el-input-number v-model="item.num" size="small" @change="handleChange" :min="1"></el-input-number> 
                        </div>
                    </el-checkbox>
                </el-checkbox-group>
            </li>
        </ul>
        <div class="cart">
            <span></span>
            <span class="highLight">{{mount}}</span>
            <span></span>
            <el-button type="primary" @click.stop="onOrder" :disabled="this.checkList.length===0"><router-link :to="{name:"Money",params:{data:this.sel}}"></router-link></el-button>
            <!-- <el-button type="primary" @click.stop="onOrder"><router-link to="/book/bookMoney"></router-link></el-button> -->
        </div>
      </div>
     </template>
    <script> 
    import bookMoney from "@/book/bookMoney"
    export default {
      components: {
        BreadCrumb,
        bookMoney
      },
      data () {
        return {
        checkAll: false,
        isIndeterminate: true,
        breadCrumbList: [],
        bookList: [],
        radio: "0",
        checkList: [],
        num: 1,
        mount: 0,
        total: 0,
        sel: []
        }
      },
      mounted () {
        this.bookList = [{
        id: "0",
        book_url: require("../assets/images/book1.jpg"),
        book_title: "",
        book_price: "39",
        num: 0
        },{
        id: "1",
        book_url: require("../assets/images/book2.jpg"),
        book_title: "",
        book_price: "45",
        num: 0
        },{
        id: "2",
        book_url: require("../assets/images/book3.jpg"),
        book_title: "",
        book_price: "59",
        num: 0
        },{
        id: "3",
        book_url: require("../assets/images/book4.jpg"),
        book_title: "",
        book_price: "30",
        num: 0
        },{
        id: "4",
        book_url: require("../assets/images/book5.jpg"),
        book_title: "",
        book_price: "25",
        num: "0"
        },{
        id: "5",
        book_url: require("../assets/images/book6.jpg"),
        book_title: "",
        book_price: "69",
        num: 0
        }
        ]
      },
      watch: {
        "checkList": function (val, oldVal) {
           
        },
        deep: true
      },
      methods: {
        onOrder () {
        },
        handleCheckedBooks () {
            this.sel = []
            this.checkList.forEach((item) => {
              this.bookList.forEach((val) => {
              if (val.id == item) {
                let tmp = {}
                tmp.id = this.bookList[Number(item)].id
                tmp.product_inf = this.bookList[Number(item)].book_title
                tmp.product_price = this.bookList[Number(item)].book_price
                tmp.product_quantity = this.bookList[Number(item)].num
                tmp.total_amount = this.bookList[Number(item)].book_price * this.bookList[Number(item)].num
                this.sel.push(tmp)
              }
            })
            // console.log(this.sel)
        })
        },
        handleChange (val) {
            this.mountPP
            this.$nextTick(function () {
            this.checkList.forEach((item) => {
            this.bookList.forEach((obj) => {
            if (obj.id === item) {
            this.total = val * obj.book_price
            }
            })
          })
        })
        },
      }
    }
    </script>

I remember that router has an attribute called keep-alive that stores the current routing state. Check it, or store the data in vux


because the route changes when you jump to the page, and when you return to the page, the vue component renders again. The
solution can be like this:
you can get a cache localstorage or vuex to store the value of this.checkList.
then watch listens for route changes,

.

watch: {

$route(to,from){
    if(to=='xx'){
        this.checkList = xxx;  .
    }
}

}


status of keep-alive cacheable components

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