1import { memo} from '@ohos.arkui.stateManagement' // should be insert by ui-plugins 2import { Entry, Text, TextAttribute, Column, Component, Button, ClickEvent } from '@ohos.arkui.component' // TextAttribute should be insert by ui-plugins 3import { State} from '@ohos.arkui.stateManagement' // should be insert by ui-plugins 4import hilog from '@ohos.hilog' 5 6@Entry 7@Component 8struct MyStateSample { 9 @State stateVar: string = 'state var'; 10 message: string = 'var'; 11 changeValue() { 12 this.stateVar+='~' 13 } 14 build() { 15 Column(undefined) { 16 Text('Hello World').fontSize(20) 17 Button(this.message).backgroundColor('#FFFF00FF') 18 .onClick((e: ClickEvent) => { 19 hilog.info(0x0000, 'testTag', 'On Click'); 20 this.changeValue(); 21 }) 22 Text(this.stateVar).fontSize(20) 23 Child({stateVar: this.stateVar} as __Options_Child) 24 } 25 } 26} 27 28@Component 29struct Child { 30 @State stateVar: string = 'Child'; 31 build() { 32 Text(this.stateVar).fontSize(50) 33 } 34} 35