查遍百度, 没有发现我要的,没办法只能自己写个:
一、首先wxml页面中每个订单要有独立的 【显示全部】和【收起】两个view;
正确的做法:
<view class="margin-sm padding-sm solid-top solids-bottom text-center" wx:if="{
{item.goods.length>2}}" bindtap="listToggle" data-lstid="{
{list_index}}">
<button class="cu-btn round sm bg-grey" style="width:180rpx;" data-sm="{
{showMore[list_index]}}" wx:if="{
{!showMore[list_index]}}">显示全部</button>
<button class="cu-btn round sm bg-grey" style="width:180rpx;" wx:if="{
{showMore[list_index]}}">收起</button>
</view>
(1)、如果goods数量大于2,那么才去显示【显示全部】或【收起】两个按钮。
(2)、【显示全部】或【收起】的展示是根据当前 page 中 data 设置的 showMore[list_index] 对应的 true 或 false 来决定的。当然首次进来设置 showMore[list_