微信小程序

小程序循环wx:for(循环标签<block>)

小程序循环wx:for

解决小程序循环问题

例如
<view class="shipin viewpadd">
     <view class="nav_hh">
       <view class="navht">在线视频</view>
       <view class="more"  hover="true" hover-class="hover_nav" hover-stay-time="1000">
       <navigator url="../avideo/video" open-type="switchTab" >更多 </navigator></view>
     </view>
     <view class="shipinbg" wx:for="{{vieo}}" wx:key="{{index}}" wx:for-item="vieorow">
        <navigator  url="../arc_video/arc_video?id={{vieorow.id}}">
        <view class="spdiv" hover="true" hover-class="hover_nav" hover-stay-time="1000">
            <view class="sppic">
              <image src="{{vieorow.img}}" mode=""></image>
            </view>
            <view class="sptxt">{{vieorow.title}}</view>
        </view>
        </navigator> 
      </view>
</view>

这里我们循环会把<view class="shipinbg">这个标签全部循环可是我只需要循环这个标签的内容。

解决方案: 

我们可以使用<block  wx:for="{{vieo}}" wx:key="{{index}}" wx:for-item="vieorow">这个标签


  <view class="shipin viewpadd">
     <view class="nav_hh">
       <view class="navht">在线视频</view>
       <view class="more"  hover="true" hover-class="hover_nav" hover-stay-time="1000">
       <navigator url="../avideo/video" open-type="switchTab" >更多 </navigator>
     </view>
     </view>
     <view class="shipinbg">
        <block  wx:for="{{vieo}}" wx:key="{{index}}" wx:for-item="vieorow">
        <navigator  url="../arc_video/arc_video?id={{vieorow.id}}">
        <view class="spdiv" hover="true" hover-class="hover_nav" hover-stay-time="1000">
            <view class="sppic">
              <image src="{{vieorow.img}}" mode=""></image>
            </view>
            <view class="sptxt">{{vieorow.title}}</view>
        </view>
        </navigator> 
        </block>
      </view>
  </view>
  
这样就只循环了里面的内容
(13)
分享:

本文由:xiaoshu168 作者:xiaoshu发表,转载请注明来源!

标签:

相关阅读