swiper的理解


一、swiper是什么?

1.swiper的理解

  • uniapp中的滑块视图容器。一般使用于轮播图、滑动切屏
  • swiper标签的默认样式:width:100%; height:150px;

2.swiper参数

参数说明
@changecurrent 改变时会触发 change 事件,event.detail = {current: current, source: source}
@transitionswiper-item 的位置发生改变时会触发 transition 事件,event.detail = {dx: dx, dy: dy},支付宝小程序暂不支持dx, dy
@animationfinish动画结束时会触发 animationfinish 事件,event.detail = {current: current, source: source}
current当前所在滑块的 index
autoplay是否自动切换
interval自动切换时间间隔
indicator-dots是否显示面板指示点
indicator-color指示点颜色
indicator-active-color当前选中的指示点颜色
active-classswiper-item 可见时的 class
current-item-id当前所在滑块的 item-id ,不能与 current 被同时指定
circular是否采用衔接滑动,即播放到末尾后重新回到开头
duration滑动动画时长

3.使用

	<swiper class="swiper"
	:current="current" 
	duration="200"
	@change="onchange">
	</swiper>

二、相关联

1.swiper-item

  • 仅可以放置在 swiper 组件中,宽高自动设置为100%(相对于父组件,其不能被子组件自动撑开)
  • swiper高度无法由swiper-item撑开(swiper的默认高度是固定的150px)
  • 因为swiper组件的元素swiper-item是设置了绝对定位的,所以里面的内容是无法撑开swiper的

2.scroll-view

  • 可滚动视图区域。用于区域滚动。
参数说明
scroll-x允许横向滚动
scroll-y允许纵向滚动
upper-threshold距顶部/左边多远时(单位px),触发 scrolltoupper 事件
lower-threshold距底部/右边多远时(单位px),触发 scrolltolower 事件
scroll-top设置竖向滚动条位置
scroll-left设置横向滚动条位置
show-scrollbar控制是否出现滚动条
refresher-enabled开启自定义刷新
refresher-triggered设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
refresher-background设置自定义下拉刷新区域背景颜色
refresher-default-style设置自定义下拉刷新默认样式,支持设置 black,white,none,none 表示不使用默认样式
触发事件说明
@scrolltoupper滚动到顶部/左边,会触发 scrolltoupper 事件
@scrolltolower滚动到底部/右边,会触发 scrolltolower 事件
@scroll滚动时触发
@refresherpulling自定义下拉刷新控件被下拉
@refresherrefresh自定义下拉刷新被触发
@refresherrestore自定义刷新被复位
@refresherabort自定义刷新被中止
  • 实例
<scroll-view scroll-y="true" 
:style="{height:fixHeight + 'rpx'}" 
lower-threshold="100"
@scrolltolower="tolower" 
refresher-enabled="true"
@refresherrefresh="onRefresh"
:refresher-triggered="triggered
class="scroll">
</scroll-view>
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值