组件 solt 中的事件问题
发布于 6 年前 作者 daiping 10867 次浏览 来自 问答

下面的示例代码:

<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 插入进入的,请帮忙解答一下

1 回复

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

回到顶部