html
<view class="wrong-rate">
<view class="wr-title">2019年08月29日</view>
<view class="{{!showMore? 'hiddenmore' : 'showmore'}}">
<view wx:for="{{rankList}}" wx:for-item="item" wx:for-index="idx" wx:key="" class="wr-list {{idx>1 ? 'more-item' : ''}}">
<view>知識點1錯誤率({{item.percentage0}}%),共{{item.amount}}人</view>
<view>其中:概念題錯誤率({{item.percentage1}}%)</view>
<view>其中:基礎(chǔ)題錯誤率({{item.percentage2}}%)</view>
<view>其中:綜合題錯誤率({{item.percentage3}}%)</view>
</view>
</view>
<block wx:if="{{rankList.length>2}}">
<view wx:if="{{showMore}}" class='' bindtap='listToggle'>
<image style='background:red;width:38rpx;height:31rpx;transform:rotate(180deg);' src="../../image/箭頭s.png"></image>
</view>
<view wx:else class='' bindtap='listToggle'>
<image style='background:red;width:38rpx;height:31rpx;' src="../../image/箭頭.png"></image>
</view>
</block>
</view>
css
.wrong-rate {
text-align: center;
}
.wr-title {
margin-bottom: 20rpx;
}
.wr-list {
font-size: 30rpx;
line-height: 50rpx;
margin-bottom: 20rpx;
}
.hiddenmore .more-item {
display: none;
}
js
Page({
data:{
showMore: false,
rankList: [
{
amount: 9.37,
percentage0: 30,
percentage1: 30,
percentage2: 30,
percentage3: 30
},
{
amount: 9.38,
percentage0: 10,
percentage1: 10,
percentage2: 10,
percentage3: 10
},
{
amount: 9.39,
percentage0: 20,
percentage1: 20,
percentage2: 30,
percentage3: 30
},
],//這里面的數(shù)據(jù)是我寫死的數(shù)據(jù),應該要通過請求獲取的
},
listToggle: function () {
this.setData({
showMore: !this.data.showMore
})
}
})