title: Taro.pageScrollTo(option)

sidebar_label: pageScrollTo

Scrolls the screen to the target location

Reference

Type

  1. (option: Option) => void

Parameters

Option

Property Type Required Description
duration number No The duration of the scrolling animation (in ms)
scrollTop number No Scrolls the screen to the target location (in px)
selector string No selector, css selector (rn not support)
complete (res: CallbackResult) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)
fail (res: CallbackResult) => void No The callback function for a failed API call
success (res: CallbackResult) => void No The callback function for a successful API call

Sample Code

  1. Taro.pageScrollTo({
  2. scrollTop: 0,
  3. duration: 300
  4. })

API Support

API WeChat Mini-Program H5 React Native
Taro.pageScrollTo ✔️ ✔️ ✔️