1. 程式人生 > >使用iview weapp元件 寫小程式 tab切換

使用iview weapp元件 寫小程式 tab切換

 

wxml:

<i-row class="tab_question">
<i-col span="24" i-class="col-class">
<i-tabs current="{{ current }}" color="#f759ab" bindchange="handleChange" >
<i-tab wx:for="{{type}}"
wx:key="{{index}}"
key="tab{{index+1}}"
id="{{index}}"
title="{{item.typename}}"
>
</i-tab>


</i-tabs>
<i-cell-group wx:for="{{type}}" wx:key="{{index}}" class="right-item {{current=='tab'+(index+1) ? 'active' : ''}}">
<i-cell
wx:for="{{item.question}}"
wx:key="{{index}}"
title="{{item.question}}"
data-id="{{item.id}}"
bindtap="answerChange"
>
</i-cell>
</i-cell-group>

</i-col>
</i-row>

js:

handleChange ({ detail }) {
this.setData({
current: detail.key,
show: detail.key
});
},

css:

.right-item{display: none}
.active{display: block}