uniapp中处理swiper轮播图

本文介绍了在uniapp中处理swiper轮播图的方法,包括自定义组件避免与默认设置冲突,设置合适的高度,以及如何像在vue中一样注册和引入组件。如果拥有接口,可以通过v-for指令实现数据动态循环展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.自己写一个swiper组件,注意组件名最好不要用swiper,注意设置swiper的高度,因为他有默认,其实就和写小程序一样,不要慌。直接复制用就行了,要是你有接口,就改成v-for循环起来就可以了。

<template>
	<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
		<swiper-item>
			<view class="swiper-item">
				<image src="../../static/img/dy.jpg" mode=""></image>
			</view>
		</swiper-item>
		<swiper-item>
			<view class="swiper-item">
				<image src="../../static/img/dy.jpg" mode=""></image>
			</view>
		</swiper-item>
	</swiper>
</template>

<script>
</script>
<style>
	swiper{
		width: 100%;
		height: 400rpx;
	}
	.swiper-item image{
		width: 100%;
		height: 400rpx;
	}
	
</style>

2.注册组件并使用,哪里需要在哪里引入。就和vue中一样。

<template>
	<view class="index">
		<view class="f-active-color">
			首页
			<index-swiper&g
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值