• uniapp制作--进步器的选择


    介绍:

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

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

    效果展示:

       

    代码展示:

            

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

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

    1. <template>
    2.   <view class="container">
    3.     <view v-for="(item, index) in productList" :key="index" class="product-item">
    4.       <view class="product-info">
    5.         <view class="product-name">{{ item.name }}view>
    6.         <view class="product-price">¥ {{ item.price }}view>
    7.       view>
    8.       <view class="product-action">
    9.         <view class="select-box">
    10.           <view class="select-minus" @click="decreaseQuantity(index)">-view>
    11.           <view class="select-quantity">{{ item.quantity }}view>
    12.           <view class="select-plus" @click="increaseQuantity(index)">+view>
    13.         view>
    14.       view>
    15.     view>
    16.   view>
    17. template>
    18. <script>
    19. export default {
    20.   data() {
    21.     return {
    22.       productList: [
    23.         { name: '商品1', price: 50, quantity: 1 },
    24.         { name: '商品2', price: 60, quantity: 1 },
    25.         { name: '商品3', price: 70, quantity: 1 },
    26.         // 可以根据需要添加更多的商品
    27.       ]
    28.     };
    29.   },
    30.   methods: {
    31.     increaseQuantity(index) {
    32.       this.productList[index].quantity++;
    33.     },
    34.     decreaseQuantity(index) {
    35.       if (this.productList[index].quantity > 1) {
    36.         this.productList[index].quantity--;
    37.       }
    38.     }
    39.   }
    40. };
    41. script>
    42. <style>
    43. .container {
    44.   padding: 20px;
    45. }
    46. .product-item {
    47.   display: flex;
    48.   justify-content: space-between;
    49.   align-items: center;
    50.   margin-bottom: 20px;
    51. }
    52. .product-info {
    53.   flex: 1;
    54. }
    55. .product-name {
    56.   font-size: 16px;
    57.   color: #333;
    58. }
    59. .product-price {
    60.   font-size: 14px;
    61.   color: #999;
    62. }
    63. .product-action {
    64.   display: flex;
    65.   align-items: center;
    66. }
    67. .select-box {
    68.   display: flex;
    69.   align-items: center;
    70. }
    71. .select-minus,
    72. .select-plus {
    73.   width: 30px;
    74.   height: 30px;
    75.   line-height: 30px;
    76.   text-align: center;
    77.   border: 1px solid #ccc;
    78.   border-radius: 4px;
    79.   font-size: 20px;
    80.   cursor: pointer;
    81. }
    82. .select-quantity {
    83.   width: 40px;
    84.   height: 30px;
    85.   line-height: 30px;
    86.   text-align: center;
    87.   margin: 0 5px;
    88. }
    89. style>

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

  • 相关阅读:
    另辟奚径-Android Studio调用Delphi窗体
    【第97题】JAVA高级技术-网络编程16(简易聊天室11:实现客户端群聊)
    Java并发编程学习二:线程安全
    【FPGA教程案例82】接口案例2——通过串口从PC发射坐标指令到FPGA,将该坐标信息控制HDMI显示屏中物体的位置
    【LINUX】CentOS有用的基础软件安装(小白版)
    【BOOST C++ 16 语言扩展】(3) Boost.Parameter
    数据导入与预处理-拓展-pandas时间数据处理01
    Lombok
    Windows 下安装NPM
    厉害了我们的“中国制造”,新能源“智造”强大到你想象不到
  • 原文地址:https://blog.csdn.net/weixin_54721820/article/details/136387939