[Daily HarmonyOS Next Knowledge] Listening for Page Size Changes, Dialog Obstruction Issues, Column Display Problems, Image Component Loading Issues, Routing Jumps
1. How to listen for real-time changes in NavPathStack size in HarmonyOS?
How to listen for real-time changes in NavPathStack size?
Current solutions in documentation: navDestinationUpdate
has three issues:
- Frequent updates trigger continuous callbacks.
- Unnecessary in some scenarios (e.g., screen off or app backgrounding).
- Inaccurate: No notification when pushing a new page changes the stack size.
Use observe.on
instead. Reference: https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-arkui-observer-V5#ZH-CN_TOPIC_0000001930676413__observeronnavdestinationswitch12
2. HarmonyOS: Page blocked by pop-up dialog?
Steps to reproduce:
- Click to pop up a dialog.
- Navigate to a login page within the dialog, resulting in the page being blocked behind the dialog.
Solution: CustomDialog
is a global pop-up with a high window hierarchy. Use window
to lower the hierarchy.
API reference: https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-window-V5
3. HarmonyOS: When Navigation uses NavigationMode.Split, can bindSheet adapt to split-screen mode?
Half-modal behavior:
- When screen width < 600vp: Bottom pop-up.
- When screen width is in
[600, 840)
: Centered pop-up. - When screen width > 840vp: Default hand-following pop-up (appears below the bound sheet node).
4. HarmonyOS: Does setting visibility
to Visibility.None
on an Image component prevent the onComplete
event from firing?
Issue: When visibility
is set to Visibility.None
, the onComplete
event does not trigger.
Explanation: The onComplete
interface returns the component's width and height (componentWidth
and componentHeight
), which require measurement to execute. If visible = false
, the component is not measured, blocking the onComplete
callback.
Solution: Keep visible = true
by default. When an image fails to load, use the onError
interface to set visible = false
.
5. HarmonyOS: What is the difference between pushDestinationByName
and pushPathByName
?
-
pushDestinationByName
binds a context object and verifies context consistency during calls. -
pushPathByName
does not verify context consistency.
Note: Different windows have different UIContexts. If used within the same window, they differ only in return values, with no other functional differences.
Top comments (0)