收藏
回答

组件 solt 中的事件问题

下面的示例代码:

<card-section >

            <view class="tabs" slot="extra">
                <view class="tab-item {{curTab===index?'active':''}}" wx:for="{{list}}" wx:key="{{index}}" bindtap="switchTab(index)">{{item.name}}</view>
            </view>
</card-section>

会提示:Component "pages/home/index" does not have a method "switchTab(index)" to handle event "tap".

实际上 switchTap 事件处理不在组件里面,而在使用组件的页面里面,从逻辑上来说也应该是在使用组件的页面里面,因为这部分逻辑是使用 slot 插入进入的,请帮忙解答一下


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

2 个回答

  • LastLeaf
    LastLeaf
    2017-12-13

    WXML 不支持 switchTab(index) 这种写法。

    2017-12-13
    有用
    回复
  • 禾店科技
    禾店科技
    2021-04-29

    楼主就很尴尬

    2021-04-29
    有用 1
    回复
登录 后发表内容