Listen for requests for changes in checkbox values in vue

how should the request interface be written if you want to listen for changes in the value of checkbox in this way?

<template>
    <div class="home-wrap">
        <HeadNav></HeadNav>
        <div class="bg-eee">
            <div class="top-menu-wrap">
                <ul class="top-menu top-menu-rank">
                    <li :class="{active:tabId===1}" data-type="1" v-on:click="checkoutTab(1,inRank)">
                        <a href="javascript:void(0);" data-trackhref="btn_comm_topnum"></a>
                    </li>
                    <li :class="{active:tabId===2}" data-type="2" v-on:click="checkoutTab(2,inRank)">
                        <a href="javascript:void(0);" data-trackhref="btn_comm_toptime"></a>
                    </li>
                </ul>
                <ul class="top-rank">
                    <li>
                        <input type="checkbox" v-model="inRank">
                        <label></label>
                    </li>
                    <li>
                        <p class="rank-current">:<span>18</span>

</li> </ul> </div> <div class="bar"></div> <div class="list-title" v-if="tabId===1"> <span class="space"></span> <span class="space-img"></span> <span class="author"></span> <span class="money"></span> </div> <div class="list-title" v-if="tabId===2"> <span class="space"></span> <span class="space-img"></span> <span class="author"></span> <span class="money"></span> </div> </div> <div class="rank-list"> <div class="dropload-up"> <div class="dropload-refresh"></div> </div> <ul v-if="tabId===1"> <li class="list-item" v-for="(item,index) in list"> <strong v-text="index+1"></strong> <img :src="item.headurl"> <p class="author" v-text="item.name">

<p class="content">{{item.cost}}

</li> </ul> <ul v-if="tabId===2"> <li class="list-item" v-for="(item,index) in list"> <strong v-text="index+1"></strong> <img :src="item.headurl"> <p class="author" v-text="item.name">

<p class="content">{{item.cost}}

</li> </ul> <div class="dropload-down"></div> </div> </div> </template> <script> import HeadNav from "../../components/HeadNav.vue"; import utils from "../../modules/utils.js" function getList(_this, type,inRank) { var api = utils.getApi("rank"); utils.http({ url: `${api}`, data: { type, inRank// }, success: function (res) { console.log(res); }, fail: function (e) { console.log("this", _this) console.log("rank",inRank) _this.list = [ { "headurl": "http://img4.imgtn.bdimg.com/it/u=105283187,2954621639&fm=27&gp=0.jpg", "name": "lxt", "cost": "237", "days": "30", "num": "10" }, { "headurl": "http://img4.imgtn.bdimg.com/it/u=105283187,2954621639&fm=27&gp=0.jpg", "name": "lxt", "cost": "237", "days": "30", "num": "10" }, { "headurl": "http://img4.imgtn.bdimg.com/it/u=105283187,2954621639&fm=27&gp=0.jpg", "name": "lxt", "cost": "237", "days": "30", "num": "10" }, { "headurl": "http://img4.imgtn.bdimg.com/it/u=105283187,2954621639&fm=27&gp=0.jpg", "name": "lxt", "cost": "237", "days": "30", "num": "10" }, { "headurl": "http://img4.imgtn.bdimg.com/it/u=105283187,2954621639&fm=27&gp=0.jpg", "name": "lxt", "cost": "237", "days": "30", "num": "10" }, { "headurl": "http://img4.imgtn.bdimg.com/it/u=105283187,2954621639&fm=27&gp=0.jpg", "name": "lxt", "cost": "237", "days": "30", "num": "10" }, { "headurl": "http://img4.imgtn.bdimg.com/it/u=105283187,2954621639&fm=27&gp=0.jpg", "name": "lxt", "cost": "237", "days": "30", "num": "10" }, { "headurl": "http://img4.imgtn.bdimg.com/it/u=105283187,2954621639&fm=27&gp=0.jpg", "name": "lxt", "cost": "237", "days": "30", "num": "10" } ]; } }); } export default { name: "app", components: { HeadNav }, data: function () { return { list: [], tabId: 1, inRank: true } }, methods: { checkoutTab: function (type,inRank) { this.tabId = type; getList(this, type,inRank); } }, watch:function () { getList(this, 1,this.inRank); }, mounted: function () { getList(this, 1,this.inRank); } } </script>
Feb.28,2021

use v-model . For more information, please see the official document form binding section ~

.

Sorry, I can't see hhh clearly on my phone. After binding an attribute of data with v-model , the attribute watch will send the request when the old value is different from the new value, but emmm does not feel very vue

.

if you feel uncomfortable like this, you might as well onchange .

< hr >

remember, you can try v-on:change to bind a function.


ide/forms.html" rel=" nofollow noreferrer "> https://cn.vuejs.org/v2/guide.

1. Binding value v-modal
2. Listen for changes watch

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