微信小程序——scroll 滚动 滚动事件

**

scroll-view

**
1)<scroll-view></scroll-view>
滚动框架
2)

<scroll-view >
<view id='one' class='scroll-view-item bc_green'></view>
<view id='two' class='scroll-view-item bc_red'></view>
<view id='three' class='scroll-view-item bc_blue'></view>
</scroll-view>

在框架内写内容

3)wxss中写样式
white-space: nowrap;——不换行
每个项目都应设置高度

.scroll-view{
  white-space: nowrap;
}
.scroll-view-item{
  height: 200px;
  /* 每个项目都应设置高度 */
}
.bc_green{
  background-color: green;
}
.bc_red{
  background-color: red;
}
.bc_blue{
  background-color: blue;
}

4)样式
在这里插入图片描述
5)需要将内容都放到一个盒子里

<scroll-view style='height:200px;'>

给框架一个高,将内容锁定

6)滚动

<scroll-view style='height:200px;'scroll-y='true'>

框架默认滚动为flase
在这里插入图片描述

**

2.绑定触碰时间

**
1)wxml

<scroll-view style='height:200px;'scroll-y='true' bindscrolltoupper="upper" bindscrolltolower="lower" bind="scroll">

bindscrolltoupper——滚动到顶部/左边
bindscrolltolower——滚动到底部/右边
bindscroll——滚动的过程
2)js

  upper:function(event){
    console.log("滚动到顶部");
  },
  lower:function(event){
    console.log("滚动到底部");
  },
  scroll:function(event){
    console.log("正在滚动");
  }

3)样式

在这里插入图片描述

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值