Taro.pageScrollTo(option)
Scrolls the screen to the target location
Type
(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
Taro.pageScrollTo({
scrollTop: 0,
duration: 300
})
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| Taro.pageScrollTo | ✔️ | ✔️ | ✔️ |