[Daily HarmonyOS Next Knowledge] Routing Back, Scroll to Middle, Worker Task Cancellation, Text Picker Multi-Level Linkage
1. Issue with router.back returning to the page in HarmonyOS?
There are 3 IndexPages: IndexPage1 = new IndexPage, IndexPage2 = new IndexPage, IndexPage3 = new IndexPage. How to return to the first IndexPage1 after routing push for these 3 IndexPages?
Implement via router.back({ url:’/2’ })
.
Reference: https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-system-router-V5#ZH-CN_TOPIC_0000001893210357__routerback
2. Can scroller.scrollToIndex(index) for HarmonyOS List slide the specified index element to the middle instead of the left?
The scroller.scrollToIndex(index)
method for List slides the specified index element to the left. Is there a way to slide it to the middle?
To display the element in the middle after scrolling, set the property to ScrollAlign.CENTER
for center alignment.
Reference: https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-container-scroll-V5#ZH-CN_TOPIC_0000001930756933__scrolltoindex
3. How to actively cancel tasks added to the queue for HarmonyOS Worker?
Use the unregisterGlobalCallObject
API to cancel tasks added to the queue.
Reference: https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-worker-V5#workerdeprecated
4. Missing bottom option for sheettype in HarmonyOS bindsheet?
- Mobile端 (Mobile): The default
preferType
isBOTTOM
(mobile only supportsBOTTOM
; settingCENTER
orPOPUP
still triggers bottom pop-up). - Tablet端 (Tablet):
CENTER
andPOPUP
can be customized (tablet cannot useBOTTOM
). For mobile端, remove thepreferType
configuration.
5. Multi-level linkage issue with HarmonyOS TextPickerDialog?
The development documentation shows that TextPicker supports two-level linkage by setting a multi-dimensional array. Does the TextPickerDialog component support two-level linkage?
The TextPickerDialog component does not support two-level linkage. Customize it using CustomDialog + TextPicker
; convert data to the format in the example.
Reference: https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-textpicker-V5
Top comments (0)