Skip to content

在tabbar的list对象中加入一个template属性,直接返回当前tab对应的template名称 #169

@tjiang4966

Description

@tjiang4966

遇到的问题

切换tab的时候,对应的template需要改变

<template name="tab-post">
  <view> 发布宝贝 </view>
</template>
<template name="tab-profile">
  <view> 个人中心 </view>
</template>

<!--index.wxml-->
<view class="container">
  <view>
    <template is="{{tabTemplate}}"></template>
  </view>
  <mp-tabbar current="{{tabIndex}}" list="{{list}}" bindchange="tabChangeHandler"></mp-tabbar>
</view>

目前,在切换tab时,只能通过更新 bindchange 返回的 detail.index 来计算模板名称
能否通过在list对象中内置一个属性来表示对应的template ?

特性方案

list: [
      {
        "text": "发布宝贝",
        "template": "tab-post",
        "iconPath": "/assets/icons/post-inactive.png",
        "selectedIconPath": "/assets/icons/post-active.png",
      },
      {
        "text": "个人中心",
        "template": "tab-profile",
        "iconPath": "/assets/icons/profile-inactive.png",
        "selectedIconPath": "/assets/icons/profile-active.png",
      }
    ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions