解决 uniapp 微信小程序 swiper里的内容不显示问题 - 个人笔记

问题描述:
页面是拥有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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值