
What is the difference between this and $ in HarmonyOS development?
Read the original article:What is the difference between this and $ in HarmonyOS development? What is the difference between this and $ in HarmonyOS development? Problem Description During HarmonyOS development learning, based on the official documentation for the @Link decorator (parent-child two-way synchronization), the following question arises: Why does line 31 in the code use the state variable with $ instead of this.yellowButtonProp ? What is the difference between this and $ ? Background Knowledge Starting from API version 9, the syntax for initializing a child component's @Link from a parent component's @State supports both: Comp ({ aLink : this . aState }) Comp ({ aLink : $aState }) Differences between this and $ : this: Refers to the current instance. Accessing or modifying this.xxx affects only the current instance and usually does not trigger re-rendering. Passing data via this does not automatically update child components. $: Represents a special data-binding mechanism.
Continue reading on Dev.to
Opens in a new tab



