HomeDocs
Skip to main content

SelectorQuery.selectViewport

Introduction

Selects the display area and can be used to obtain information such as the size and scroll position of the display area. It returns a NodesRef object instance.

Parameters

None

Return Value

NodesRef

Sample Code

Page({
selectViewport() {
dlt
.createSelectorQuery()
.selectViewport()
.scrollOffset((res) => {
console.log('Node Information:', res);
// res.id // Node's ID
// res.dataset // Node's dataset
// res.scrollLeft // Node's horizontal scroll position
// res.scrollTop // Node's vertical scroll position
})
.exec();
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.