微信小程序-uniapp使用<scroll-view >组件实现卡片左滑功能在电脑端小程序版不生效问题

<scroll-view class="scroll-view_H" :scroll-x="greaterThan" @scroll="scroll" scroll-left="120">
	<view id="demo1" class="scroll-view-item_H" v-for="(item,index) in vipList" :key="index">
		<view class="flex-between">
			<text style="color:#7d5723 ;font-size: 8px;font-weight: 600;">{{item.name}}</text><text class="car-type">{{item.type}}</text>
		</view>
		<view class="flex-between-center">
		<view>¥{{item.amount}}</view>
		<view style="margin-right: 14rpx;margin-top: 12rpx;">
			<image src="../../../static/vip.png" style="width: 20px;height: 20px;"></image>
		</view>
		</view>
	</view>
</scroll-view>

改用swiper组件就可以啦~附上参考代码

<swiper class="swiper" :display-multiple-items="multipleItems">
	<swiper-item v-for="(item,index) in vipList" :key="index" :item-id="item.id">
		<view class="vip-card-mini" @click="changeVip(index, item)":style="{'margin-right':index== vipList.length-1?'20rpx':'0','border':index === selectedIndex?'1px solid #cfa16c':'none','min-width':greaterThan?'28%':'30%'}">
			<view class="flex-between">
				<view style="color:#7d5723 ;font-size: 12px;font-weight: 600;">{{item.name}}</view>
					<view style="color: #905723;font-size: 10px;margin-right: 8rpx;text-align: right;">普通VIP
					</view>
			</view>
			<view class="flex-between-center">
					<view class="amount">¥{{item.amount}}</view>
					<view class="vip-img"><image src="/static/vip.png" style="width: 20px;height: 20px;"></image></view></view>
			</view>
	</swiper-item>
	<view v-if="multipleItems==3">
         //必写 不然会报错
	    <swiper-item v-if="vipList.length<multipleItems"></swiper-item>
	    <swiper-item v-if="vipList.length<multipleItems-1"></swiper-item>
	</view>
</swiper>
<script>
export default {
		data() {
			return {
                // vipList数组长度 因为这个功能需求是要展示三个卡片 如果不动态写multipleItems控制台<swiper-item>数量相关错误信息
                multipleItems:3,
            }
        }
}
</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值