当前位置: 首页 > news >正文

uniapp制作--进步器的选择

介绍:

        进步器的选择,一般用于商城购物选择物品数量的场景

        注意:该输入框只能输入大于或等于0的整数    

效果展示:

   

代码展示:

        

    以下是一个简单的购物车页面示例,包括选择商品和显示数量的功能:

        在这个示例中,我们展示了一个简单的购物车页面,包括商品名称、价格和数量。通过点击 "+" 和 "-" 按钮来增加或减少商品数量,并保证数量不少于 1。你可以根据实际需求和设计风格进行修改和扩展。

<template><view class="container"><view v-for="(item, index) in productList" :key="index" class="product-item"><view class="product-info"><view class="product-name">{{ item.name }}</view><view class="product-price">¥ {{ item.price }}</view></view><view class="product-action"><view class="select-box"><view class="select-minus" @click="decreaseQuantity(index)">-</view><view class="select-quantity">{{ item.quantity }}</view><view class="select-plus" @click="increaseQuantity(index)">+</view></view></view></view></view>
</template><script>
export default {data() {return {productList: [{ name: '商品1', price: 50, quantity: 1 },{ name: '商品2', price: 60, quantity: 1 },{ name: '商品3', price: 70, quantity: 1 },// 可以根据需要添加更多的商品]};},methods: {increaseQuantity(index) {this.productList[index].quantity++;},decreaseQuantity(index) {if (this.productList[index].quantity > 1) {this.productList[index].quantity--;}}}
};
</script><style>
.container {padding: 20px;
}.product-item {display: flex;justify-content: space-between;align-items: center;margin-bottom: 20px;
}.product-info {flex: 1;
}.product-name {font-size: 16px;color: #333;
}.product-price {font-size: 14px;color: #999;
}.product-action {display: flex;align-items: center;
}.select-box {display: flex;align-items: center;
}.select-minus,
.select-plus {width: 30px;height: 30px;line-height: 30px;text-align: center;border: 1px solid #ccc;border-radius: 4px;font-size: 20px;cursor: pointer;
}.select-quantity {width: 40px;height: 30px;line-height: 30px;text-align: center;margin: 0 5px;
}
</style>

        以上是一个使用原生态uniapp制作的进步器。

http://www.lryc.cn/news/311751.html

相关文章:

  • 前端高频面试--查缺补漏篇
  • 【计算机学习】-- 网页视频加速
  • 系统运维-Linux配置C、C++、Go语言编译环境
  • 【设计模式】(二)设计模式六大设计原则
  • go-zero官网
  • Redis的应用场景以及常见问题(持续更新)
  • 前端添加压缩包内文件名称校验
  • redis02 安装
  • #QT(QT时钟)
  • T-RAG:结合实体检测的增强检索生成模型
  • u-boot: NAND 驱动简介
  • 史上最全的大数据开发八股文【自己的吐血总结】
  • 数据库学习案例20240304-mysql数据库案例总结(碎片,统计信息)
  • 【小白友好】LeetCode 删除并获得点数
  • c#委托、lambda、事件
  • 每日一练——9×9乘法表
  • 大白话解析LevelDB:ShardedLRUCache
  • GDOI2024游记
  • 学编程怎么样才能更快入手,编程怎么简单易学
  • Android 通知--判断通知是否有跳转
  • 【计算机网络】IO多路转接之poll
  • 性能比较:in和exists
  • 【Java设计模式】五、建造者模式
  • nginx代理minio教程 避坑过的教程 避开SignatureDoesNotMatch
  • Linux进程详细介绍
  • 2024年3月产品认证基础考试简答题及答案
  • 嵌入式蓝桥杯做题总结
  • Spring Boot 常用注解大全
  • (MATLAB)第十二章-数列与极限
  • OJ输入问题+准备