最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JS+Vue實(shí)現(xiàn)三級全選單選

 更新時間:2022年07月15日 14:39:40   作者:webqingyou  
這篇文章主要為大家詳細(xì)介紹了JS+Vue實(shí)現(xiàn)三級全選單選,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了JS+Vue實(shí)現(xiàn)三級全選單選的具體代碼,供大家參考,具體內(nèi)容如下

HTML

<div class="demand-class">
    <div class="demand-class-title">需求分類</div>
    <div class="demand-check">
        <input
        class="collect-top-checked"
        type="checkbox"
        v-model="demandChecked"
        @change="handledemandChecked"
        />全選
    </div>
    <div
        class="package-type package-type2"
        v-for="(itns, itds) in classiFications"
        :key="itns.id"
    >
        <div class="package-type-title upgrading-title">
        <input
            class="collect-top-checked"
            type="checkbox"
            v-model="ficationsCheck[itds]"
            @change="handleFicationsCheck(itds)"
        />{{ itns.name }}
        <div class="title-bor"></div>
        </div>
        <div class="package-type-content">
        <div
            v-for="cd in itns.children"
            :key="cd.id"
            class="package-type-list"
        >
            <input
            class="collect-top-checked"
            type="checkbox"
            :value="cd.id"
            @change="handlechildrenCheck(itds, cd.id)"
            v-model="childrenCheck"
            />
            <div>{{ cd.name }}</div>
        </div>
        </div>
    </div>
</div>

js

data () {
? ? classiFications: [], //需求分類 接口給的集合
? ? demandChecked: false, // 需求分類全選
? ? ficationsCheck: [], //一級分類的單個全選
? ? childrenCheck: [], //二級分類的全選
? ? demandCheckedShow: false, //二級全選不觸發(fā)接口
}
?
methods: {
? ? // 需求分類全選
? ? handledemandChecked() {
? ? ? ??
? ? ? ? if (this.demandChecked) {
? ? ? ? ? ? this.classiFications.forEach((it, is) => {
? ? ? ? ? ? this.ficationsCheck[is] = true;
? ? ? ? ? ? this.handleFicationsCheck(is);
? ? ? ? ? ? });
? ? ? ? } else {
? ? ? ? ? ? this.classiFications.forEach((it, is) => {
? ? ? ? ? ? this.ficationsCheck[is] = false;
? ? ? ? ? ? this.handleFicationsCheck(is);
? ? ? ? ? ? });
? ? ? ? }
? ? ? ? },
? ? ? ? //一級分類所選
? ? ? ? async handleFicationsCheck(id) {
? ? ? ??
? ? ? ? this.demandCheckedShow = true;
? ? ? ? let tmp = this.classiFications[id].childrenIds; //當(dāng)前選擇的id子集合
? ? ? ? let tmpAdd = this.childrenCheck; //當(dāng)前選擇的id子集合
? ? ? ? if (this.ficationsCheck[id]) {
? ? ? ? ? ? tmp.forEach((item) => {
? ? ? ? ? ? for (let i = 0; i < tmp.length; i++) {
? ? ? ? ? ? ? ? if (tmpAdd.indexOf(item) === -1) {
? ? ? ? ? ? ? ? this.childrenCheck.push(item);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? });
? ? ? ? } else {
? ? ? ? ? ? tmp.forEach((item) => {
? ? ? ? ? ? for (let i = 0; i < tmp.length; i++) {
? ? ? ? ? ? ? ? if (tmpAdd.indexOf(item) !== -1) {
? ? ? ? ? ? ? ? this.childrenCheck.splice(this.childrenCheck.indexOf(item), 1);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? });
? ? ? ? }
? ? ? ? // this.handleType();
? ? ? ? this.currentPage = 0;
? ? ? ? await this.initSolutionAllPage();
? ? ? ? this.demandCheckedShow = false;
? ? ? ? },
? ? ? ? //二級分類所選
? ? ? ? handlechildrenCheck(ids, cd) {
? ? ??
? ? ? ? console.log(cd);
? ? ? ? let cont = 0;
? ? ? ? // let conts = 0;
? ? ? ? let tmp = this.classiFications[ids].childrenIds; //當(dāng)前選擇的id子集合
? ? ? ? let tmpAdd = this.childrenCheck; //當(dāng)前選擇的id子集合
? ? ? ? if (this.ficationsCheck[ids]) {
? ? ? ? ? ? tmp.forEach((item) => {
? ? ? ? ? ? for (let i = 0; i < tmp.length; i++) {
? ? ? ? ? ? ? ? if (tmpAdd.indexOf(item) === -1) {
? ? ? ? ? ? ? ? this.ficationsCheck[ids] = false;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? });
? ? ? ? } else {
? ? ? ? ? ? let tmpl = tmp.length === 1 ? 1 : tmp.length - 1;
? ? ? ? ? ? tmp.forEach((item) => {
? ? ? ? ? ? for (let i = 0; i < tmpl; i++) {
? ? ? ? ? ? ? ? if (tmpAdd.indexOf(item) !== -1) {
? ? ? ? ? ? ? ? // console.log(item);
? ? ? ? ? ? ? ? cont = cont + 1;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? });
? ? ? ? ? ? if (cont === this.classiFications[ids].childrenIds.length) {
? ? ? ? ? ? this.ficationsCheck[ids] = true;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? // this.handleType();
? ? ? ? if (!this.demandCheckedShow) {
? ? ? ? ? ? this.currentPage = 0;
? ? ? ? ? ? this.initSolutionAllPage();
? ? ? ? }
? ? },
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

灌云县| 台江县| 胶南市| 五指山市| 贺兰县| 泾源县| 东辽县| 平潭县| 崇仁县| 丰都县| 隆德县| 西青区| 图片| 九龙县| 织金县| 阿瓦提县| 南澳县| 大安市| 上饶县| 焉耆| 商河县| 乌审旗| 鹿泉市| 澄城县| 盐源县| 凯里市| 凌源市| 思南县| 桐柏县| 碌曲县| 彰化县| 梅州市| 五常市| 湘潭县| 阜城县| 金坛市| 常熟市| 连城县| 沁阳市| 甘孜县| 徐闻县|