securityzhou
<view>
<SearchInput></SearchInput>
<Tabs tabs="{{tabs}}" bindstabsItemChange="handletabsItemChange">
<block wx:if="{{tabs[0].isActive}}">0</block>
<block wx:elif="{{tabs[1].isActive}}">1</block>
<block wx:elif="{{tabs[2].isActive}}">2</block>
</Tabs>
</view>

这里bindstabsItemChange="handletabsItemChange",他绑定的事件是以下代码

  methods: {
        handleItemTap(e){
            const {index}=e.currentTarget.dataset;
            this.triggerEvent("tabsItemChange",{index})
        }
    }
})
tabsItemChange的绑定事件就是在tabsItemChange前面加上bind,等于bindtabsItemChange,我们将
handletabsItemChange事件定义传给绑定函数

handletabsItemChange定义如下:
 handletabsItemChange(e){
        const {index}=e.detail;
        let {tabs}=this.data;
        tabs.forEach((v,i)=>i===index?v.isActive=true:v.isActive=false);
        this.setData({
            tabs
        })
    },

 

此是父组件给子组件传递参数的过程

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-11-18
  • 2022-01-17
  • 2021-07-13
  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-19
  • 2021-12-30
  • 2022-01-15
  • 2021-05-26
  • 2022-01-07
  • 2022-12-23
相关资源
相似解决方案