复选框(全选)(单选)(删除)

<template>
    <view class="coupon">
        <u-navbar :is-back="true" :title="$t('pages.coupon.title')" :background="backgroundStyle" title-color="#222222"
            back-icon-color="#2F394E">
            <view class="slot-wrap" slot="right">
                <!--<u-icon name="moments" size="28" @click="addCoupon"> </u-icon>-->
                <image src="../../static/me/close-icon.png" style="width: 10pt;height: 10pt;" mode=""
                    @click="addCoupon"></image>
            </view>
        </u-navbar>
        <view class="children">
            <view :class="item.status === '0'? 'body red':(item.status === '1'? 'body grey':'body bode')"
                v-for="(item, index) in list" :checked="item.checked">
                <view class="item">
                    <view class="header">
                        { {$t("pages.coupon.header")}}
                    </view>
                    <u-checkbox-group class="xuanze" @change="checkboxGroupChange">
                        <view>
                            <u-checkbox @change="checkboxChange" v-model="item.checked" :name="item.id" :key="index"
                                style="background-color: #FFFFFF;width: 60%;transform: scale(0.7);"></u-checkbox>
                        </view>
                    </u-checkbox-group>
                    <view class="price">
                        { {item.cuttingAmount}}
                        <text style="font-weight: 100;font-size: 13px;">{ {$t("pages.about.about.to")}}</text>
                
                    </view>
                    <view class="valuel">
                        { {$t("pages.transaction.effectiveEndDate")}}{ {getTime(item.effectiveEndDate)}}
                    </view>

                    <u-row style="margin-top: 2px;">
                        <u-col span="9" style="padding-left: 5px;padding-right: 0;">
                            <view style="cursor:pointer;color: #222222;margin-top: 19px; margin-left: 6px;" class="xia">
                                { {$t("pages.coupon.code")}}{ {item.couponNumber}}
                            </view>
                        </u-col>
                        <u-col v-if="item.status === '0'" span="3" style="padding: 0;margin-top: 20px ;">
                            <image src="../../static/me/Frame_copy.png"
                                style="width: 12pt;height: 12pt;float: left;margin-top: 2px;margin-left: 5px;"></image>
                            <view @click="toCopy(item)" style="cursor:pointer;color: #222222;margin-left: 25px;" class="xia">
                                { {$t('common.btn.copy')}}
                            </view>
                        </u-col>
                    </u-row>
                </view>
            </view>
        </view>
        <view class="foot_btn">

            <view style="width: 50%;float:left;margin: 10px;">
                <view style="top: auto;text-align: center;margin-left: 20%;">
                    <u-icon name="shanchu" custom-prefix="custom-icon" size="46" :disabled="deleteBtn"
                        style="margin-top: -3px;" @tap="()=>toDelete()"> </u-icon>
                    <br&g

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在JavaScript和HTML中,创建一个购物车的复选框全选/单选功能可以通过以下几个步骤完成。这里是一个基本的示例: ```html <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <title>购物车复选框</title> <style> .cart-checks { display: flex; gap: 10px; /* 控制复选框之间的间距 */ } .check-all { margin-right: 10px; } </style> </head> <body> <h2>购物车商品选择</h2> <div class="cart-checks"> <!-- 商品项,这里的数量可以动态添加 --> <label class="checkbox" for="item1"> <input type="checkbox" id="item1" value="商品1"> 商品1 </label> <label class="checkbox" for="item2"> <input type="checkbox" id="item2" value="商品2"> 商品2 </label> <!-- 更多商品... --> <button id="checkAll">全选</button> <button id="uncheckAll">全不选</button> </div> <script> // 获取所有复选框全选按钮 const checkboxes = document.querySelectorAll('input[type="checkbox"]'); const checkAllBtn = document.getElementById('checkAll'); const uncheckAllBtn = document.getElementById('uncheckAll'); // 全选按钮事件处理 checkAllBtn.addEventListener('click', function() { checkboxes.forEach(function(checkbox) { checkbox.checked = true; }); }); // 全不选按钮事件处理 uncheckAllBtn.addEventListener('click', function() { checkboxes.forEach(function(checkbox) { checkbox.checked = false; }); }); // 当复选框状态改变时,检查是否有被选中的 checkboxes.forEach(function(checkbox) { checkbox.addEventListener('change', function() { if (checkboxes.filter(checkbox => checkbox.checked).length === checkboxes.length) { checkAllBtn.textContent = '全选'; } else { checkAllBtn.textContent = '全不选'; } }); }); </script> </body> </html> ``` 这个示例展示了如何使用JavaScript控制复选框全选和全不选操作,并且当任何一个复选框的状态变化时,会自动更新全选按钮的状态。你可以根据实际需求对商品列表和样式进行扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值