[Daily HarmonyOS Next Knowledge] Two-way Data Binding, Child Component Radius, Video Download Hide, String Replacement, Routing Issues
1. HarmonyOS value passing with $$?
https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-two-way-sync-V5
$$ is a built-in two-way synchronization operator for components, providing a reference to TS variables for system-built components. This keeps TS variables in sync with the internal state of system-built components, which is different from state variables.
2. Which container component in HarmonyOS can set the angle and radius of child components?
Angle and radius of child components can be set using absolute positioning. Coordinates of child component vertices can be calculated via Math functions.
Reference: https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-universal-attributes-location-V5#position
3. How to hide the download button for video tags in HarmonyOS Web components?
The download button can be hidden by adding controls controlslist="nodownload" to the video tag. If this doesn’t work, use CSS to hide it:
video::-internal-media-controls-download-button {
display: none;
}
video::-webkit-media-controls-enclosure {
overflow: hidden;
}
video::-webkit-media-controls-panel {
width: calc(100% + 30px);
}
4. After using Navigation routing in HarmonyOS, the second-level page sets hideToolBar to true, but the custom navigation bar header remains blank and doesn’t display.
Example workflow:
- In the first-level page, use
pushDestinationto stack the second-level page. - In the second-level page, use
hideToolBar(true)to hide the toolbar. - On pages where the toolbar should be shown, set
hideToolBarto false.
5. Is there a way to replace a specific substring in a string with another character in HarmonyOS?
For example, replace 4 with 0 in 1243456748.
Reference demo:
let reg: RegExp = new RegExp('apple', 'g');
let str = 'an apple apple apple apple.';
let newStr = str.replace(reg, 'fruit');
console.log(newStr); // Output: an fruit fruit fruit fruit
this.message = newStr;
Top comments (0)