收藏
回答

问一个关于{{}}的小白问题

<template name='report_head'>

<view class="tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="swichNav">1</view>

</template>


这里我打算进行循环遍历,有没有办法将下图画圈进行自增,


{{0++}},不起用

回答关注问题邀请回答
收藏

2 个回答

  • Mr.Right
    Mr.Right
    2018-07-29

    0写成index就行了

    2018-07-29
    有用
    回复 1
    • Enhoo
      Enhoo
      2018-07-29

      嗯不行,

      要用wx:for-index,现在可以了~

      2018-07-29
      回复
  • 2018-07-28

    <template name='report_head'>

    <view class="tab-item {{currentTab==0?'active':''}}" wx:for="{{ arr }}" data-current="{{  index }}" bindtap="swichNav">1</view>

    </template>


    2018-07-28
    有用
    回复 4
    • Enhoo
      Enhoo
      2018-07-28

      谢谢大佬,不过没有解决。

      我想要进行的遍历:


      <block wx:for="{{p1_guilds}}" wx:for-item="report_headItem" wx:key="report_headIndex">

      <template is="report_head" data="{{...report_headItem,index,ids}}" />

      </block>


      <template name='report_head'>

      <view class="tab-item {{currentTab==0(这里我想让他自增)?'active':''}}" data-current="0(这里我想让他自增)" bindtap="swichNav">1</view>

      </template>


      2018-07-28
      回复
    • Enhoo
      Enhoo
      2018-07-28回复Enhoo

      谢谢大佬,不过没有解决。

      我想要进行的遍历:


      <block wx:for="{{p1_guilds}}" wx:for-item="report_headItem" wx:key="report_headIndex">

      <template is="report_head" data="{{...report_headItem,index,ids}}" />

      </block>


      <template name='report_head'>

      <view class="tab-item {{currentTab==0(这里我想让他自增)?'active':''}}" data-current="0(这里我想让他自增)" bindtap="swichNav">1</view>

      </template>


      效果图

      2018-07-28
      回复
    • 2018-07-29回复Enhoo

      用wx:for-index也不可以吗

      2018-07-29
      回复
    • Enhoo
      Enhoo
      2018-07-29回复

      可以了,谢谢大佬

      2018-07-29
      回复
登录 后发表内容