1import { 2 memo, 3 __memo_context_type, 4 __memo_id_type, 5 State, 6 StateDecoratedVariable, 7 MutableState, 8 stateOf, 9 observableProxy 10} from '@ohos.arkui.stateManagement' // should be insert by ui-plugins 11 12import { 13 Text, 14 TextAttribute, 15 Column, 16 Component, 17 Button, 18 ButtonAttribute, 19 ClickEvent, 20 UserView, 21 ButtonType, 22 ButtonStyleMode, 23 ButtonOptions, 24 ButtonRole, 25 Color, 26 NavDestination, 27 NavPathStack, 28 NavDestinationContext, 29 Callback 30} from '@ohos.arkui.component' // TextAttribute should be insert by ui-plugins 31 32import hilog from '@ohos.hilog' 33 34@Component 35export struct ButtonTest { 36 @State stateVar: string = 'state var'; 37 message: string = 'var'; 38 39 changeValue() { 40 this.stateVar += '~' 41 } 42 43 build() { 44 NavDestination() { 45 Column(undefined) { 46 Text('Hello World').fontSize(20) 47 Button('OK', 48 { 49 type: ButtonType.Normal, 50 stateEffect: false, 51 } as ButtonOptions).fontColor(Color.Pink).fontWeight(600).fontSize(30) 52 Button(this.message) 53 .backgroundColor('#FFFF00FF') 54 .type(ButtonType.Circle) 55 .stateEffect(false) 56 .role(ButtonRole.ERROR) 57 .onClick((e: ClickEvent) => { 58 hilog.info(0x0000, 'testTag', 'On Click'); 59 this.changeValue() 60 }) 61 Text(this.stateVar).fontSize(20) 62 Child({ stateVar: this.stateVar } as __Options_Child) 63 } 64 } 65 .title('Button基础功能测试') 66 } 67} 68 69@Component 70struct Child { 71 @State stateVar: string = 'Child'; 72 73 build() { 74 Text(this.stateVar).fontSize(50) 75 } 76}