微信小程序API 位置


本文整理自网络,侵删。

wx.pageScrollTo(OBJECT)

基础库 1.4.0 开始支持,低版本需做兼容处理

将页面滚动到目标位置。

OBJECT参数说明:

属性 类型 默认值 必填 说明 最低版本
 scrollTop number 否 滚动到页面的目标位置,单位 px 
 duration number 300否  滚动动画的时长,单位 ms 
 selector string 否  选择器 2.7.3
 success function 否  接口调用成功的回调函数 
 fail function 否  接口调用失败的回调函数 
 complete function 否  接口调用结束的回调函数(调用成功、失败都会执行) 

selector 语法

selector类似于 CSS 的选择器,但仅支持下列语法。

  • ID选择器:#the-id
  • class选择器(可以连续指定多个):.a-class.another-class
  • 子元素选择器:.the-parent > .the-child
  • 后代选择器:.the-ancestor .the-descendant
  • 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
  • 多选择器的并集:#a-node, .some-other-nodes

示例代码:

wx.pageScrollTo({
  scrollTop: 0,
  duration: 300
})



标签:微信小程序

相关阅读 >>

微信小程序api 背景音频-暂停播放

微信小程序 服务端能力

sdk数据库 aggregate记录分组

微信小程序 运力方使用onorderquery

微信小程序云开发 拓展功能

微信小程序 卡券

微信小程序 广告-广告分析数据接口

微信小程序 小程序宿主环境

微信小程序api 绘图stroke(对当前路径进行描边)

微信小程序api 绘图createlineargradient(创建线性渐变)

更多相关阅读请进入《微信小程序》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...