zoukankan      html  css  js  c++  java
  • 微信小程序 for循环嵌套怎么取值

    外层循环正常嵌套,内层循环嵌套的时候,把item.swiper_buy作为数组循环wx:for="{{item.swiper_buy}}",然后给item重新命名wx:for-item="cell",内部循环的时候,就是{{cell.属性}}

    wxml:

        <block wx:for="{{swiper_object}}" wx:key="index">
        <swiper-item>
          <view class='swiper_in'>
            <view class='head_img'>
              <image src="{{item.head_img}}"></image>
              <view class='head_in'>
                <view class='card_name'>嘻哈帮街舞.{{item.card_name}}</view>
                <view class="card_i">{{item.card_use}}</view>
                <view class='use_region'>{{item.card_region}}</view>
              </view>
            </view>
            <view class='buy_list'>
              <block wx:for="{{item.swiper_buy}}" wx:for-item="cell" wx:key="index">
                <view class="buy_item {{num==index?'current':''}}"   data-index="{{index}}" catchtap='switchTab'>
                  <view class='buy_price'>
                    <view class='card_price'>¥{{cell.buy_price}}</view>
                    <view class='nk_species'>{{cell.card_species}}</view>
                  </view>
                  <view class='buy_zs'>{{cell.buy_send}}</view>
                </view>
              </block>
            </view>
          </view>
        </swiper-item>
        </block>

      js:

    data: {
        num: 0,
        swiper_object:[
          {
            swiper_buy: [
              {
                buy_price: "1100",
                card_species: "年卡D",
                buy_send: "购买1课点"
              },
              {
                buy_price: "2200",
                card_species: "年卡C",
                buy_send: "购买9课点"
              },
              {
                buy_price: "3300",
                card_species: "年卡B",
                buy_send: "购买3课点"
              }
            ],
            head_img:"../../images/head_img1.png",
            card_name:"次卡",
            card_use:"49/课点",
            card_region:"本课点全国通用"
          },
          {
            swiper_buy: [
              {
                buy_price: "1400",
                card_species: "一年通",
                buy_send: "有效期内享受日课程课"
              },
              {
                buy_price: "2500",
                card_species: "两年通",
                buy_send: "有效期内享受日课程课"
              },
              {
                buy_price: "46000",
                card_species: "单店通",
                buy_send: "赠本企业续存期内"
              }
            ],
            head_img: "../../images/head_img2.png",
            card_name: "少儿畅舞卡",
            card_use: "本地使用",
            card_region: "有效期内可以享受日常课"
          },
        ]
      }
    

      参考:https://blog.csdn.net/weixin_38930535/article/details/79152627

      参考:https://www.cnblogs.com/handsomeBoys/p/6599062.html

  • 相关阅读:
    MySQL-DQL查询语句的其他方法查询
    MySQL-SQL的分类以及基本的操作
    1-1-4-2 Java se-常量&变量-作用域
    1-1-4-1 java se-常量&变量-基本数据类型
    1-1-2-1 java se-helloworld原理—java代码的编译和运行逻辑
    1-1-1-2 Java se-java运行环境-jvm虚拟机的跨平台性以及和jdk,jre之间的关系
    1-1-1-1 java se-java运行环境-基本单位bit和Byte
    递归
    Ultra-QuickSort (POJ 2299)树状数组+离散化
    Color the ball(HDU1556)树状数组
  • 原文地址:https://www.cnblogs.com/jvziking/p/9451294.html
Copyright © 2011-2022 走看看