问题描述:
页面是拥有3个item的swiper,每个swiper都是一个长滚动列表,每个列表里都是一个个item(在这里我封装成名为dataItem的组件),其中给dataItem组件传递“itemdata”和“currentType”参数,但是itemdata显示没问题,下面的按钮部分不显示(如果用户左右手动切换swiper又可以显示),尝试了compute、v-if、setTimeout、nextTick等都没有效果,后来才发现是currentType 的问题,于是把currentType 从v-if条件里面去掉。盲猜是swiper组件current参数的问题,在此记录一下。
出问题的代码:
<view class="item-text-section">
<view>
号码:{{itemdata.phoneNum}}
</view>
<view>
地址:{{itemdata.positionAddress}}
</view>
</view>
<template v-if="currentType === 1">
<template v-if="typeName.indexOf('待确认')>-1">
<view>
<u-button type="primary" text="确定" @click="confireOrderHandle(itemdata.id)">确认</u-button>
</view>
</template>
<view>
<u-button @click="watchInfo(itemdata.id)">查看详情</u-button>
</view>
</template>
解决问题后的代码
<view class="item-text-section">
<view>
号码:{{itemdata.phoneNum}}
</view>
<view>
地址:{{itemdata.positionAddress}}
</view>
</view>
<template>
<template v-if="typeName.indexOf('已完成')>-1">
<view>
<u-button type="primary" text="确定" @click="confireOrderHandle(itemdata.id)">确认</u-button>
</view>
</template>
<template v-if="typeName.indexOf('准备中')>-1">
<view>
<u-button @click="watchInfo(itemdata.id)">查看详情</u-button>
</view>
</template>
</template>