Skip to main content
Version: Next

Taro.createSelectorQuery()

Returns a SelectorQuery object instance. In a custom component or a page that contains a custom component, use this.createSelectorQuery() instead.

Reference

Type

() => SelectorQuery

Parameters

Sample Code

const query = Taro.createSelectorQuery()
query.select('#the-id').boundingClientRect()
query.selectViewport().scrollOffset()
query.exec(function(res){
res[0].top // The upper boundary coordinate of the #the-id node
res[1].scrollTop // The vertical scroll position of the display area
})

API Support

APIWeChat Mini-ProgramH5React Native
Taro.createSelectorQuery✔️✔️