HTML5-购物车全选--小计-

1、楼梯样式兼容—–index1.html

在火狐浏览器上显示有问题。
动态滚动条—-谷歌是body,火狐、ie用html,
这里写图片描述
所以用html,body
Bol值写不写均可。

2、购物车对火狐的兼容—–index2.html\

这里写图片描述

3、淘宝购物车商品事件

这里写图片描述
保留两位小数

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用uniapp checkbox-group实现购物车全的示例代码: 1. 在template中添加checkbox-group和checkbox组件 ``` <template> <view> <checkbox-group bindchange="selectAllChange"> <checkbox value="all" checked="{{allSelected}}">全</checkbox> </checkbox-group> <view v-for="(item, index) in cartList"> <checkbox value="{{item.id}}" checked="{{item.selected}}" bindchange="selectChange">{{item.name}}</checkbox> </view> </view> </template> ``` 2. 在script中添加data属性和方法 ``` <script> export default { data() { return { cartList: [], // 购物车列表 allSelected: false // 是否全 } }, onShow() { // 获取购物车列表 this.getCartList() }, methods: { // 获取购物车列表 getCartList() { // 省略获取购物车列表的代码 }, // 单个商品中状态改变事件 selectChange(event) { const id = event.target.value const selected = event.detail.value.length > 0 // 更新购物车列表中对应商品的中状态 this.cartList = this.cartList.map(item => { if (item.id === id) { item.selected = selected } return item }) // 判断是否全 this.checkAllSelected() }, // 全状态改变事件 selectAllChange(event) { const selected = event.detail.value.length > 0 // 更新购物车列表中所有商品的中状态 this.cartList = this.cartList.map(item => { item.selected = selected return item }) // 更新全状态 this.allSelected = selected }, // 检查是否全 checkAllSelected() { const selectedList = this.cartList.filter(item => item.selected) this.allSelected = selectedList.length === this.cartList.length } } } </script> ``` 3. 在style中添加样式 ``` <style> .uni-checkbox { margin-right: 10px; } </style> ``` 4. 注意事项 - checkbox-group组件中的value值需要设置为all,并且checked值绑定allSelected变量; - checkbox组件中的value值需要设置为对应商品的id,并且checked值绑定商品的selected属性; - selectChange方法中需要更新对应商品的selected属性,并调用checkAllSelected方法检查是否全- selectAllChange方法中需要更新所有商品的selected属性,并更新allSelected变量; - checkAllSelected方法中需要筛出已中的商品,判断是否全

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值