收藏
回答

请问如何按照名字判断来跳转相应的页面?(选到苹果跳转苹果,选到葡萄跳到葡萄)

wxml:
<view class="navRight">
    <block wx:for="{{categoryData}}">
      <view  class="navRight-main-item" wx:if="{{currentIndex == index}}">
        <block wx:for="{{item.list}}" wx:for-item="subitem">
          <view  class="navRight-main-item-list">
            <block wx:for="{{subitem.subList}}" wx:for-item="descitem" >
              <navigator data-img="{{descitem.descUrl}}" data-text="{{descitem.descTitlt}}" bindtap="navigateToApple">
                  <!-- <view> -->
                    <image src="{{descitem.descUrl}}"></image>
                    <text>{{descitem.descTitlt}}</text>
                  <!-- </view> -->
              </navigator>
            </block>
          </view>
        </block>
      </view>
    </block>
  </view>



js:
var categoryData={
  "code":1,
  "success":"ok",
  "data":
  [
    {
      "title":"苹果",
      "list":
      [
        {
          "subList":
          [
            {
              descTitlt:"苹果",
              descUrl:"/images/small_apple.jpeg"
            }
          ]
        }
      ]
    },
    {
      "title":"葡萄",
      "list":
      [
        {
          "subList":
          [
            {
              descTitlt:"葡萄",
              descUrl:""
            }
          ]
        }
      ]
    },
    {
      "title":"敬请期待",
      "list":
      [
        {
          "subList":[]
        }
      ]
    }
  ]
}
export default categoryData;


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

1 个回答

  • 卡卡
    卡卡
    2021-07-14

    绑定点击事件跳转,在元素上绑定一个属性,点击事件获取属性判断是那个元素,跳转相应页面

    2021-07-14
    有用 1
    回复
登录 后发表内容