diff --git a/code/HelloWorld/entry/src/main/ets/entryability/EntryAbility.ets b/code/HelloWorld/entry/src/main/ets/entryability/EntryAbility.ets index 964c580b66c3d336b49258e9941f1be0032127eb..7080b7f8ea79b15abaad81f192af64f460c1d566 100644 --- a/code/HelloWorld/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/HelloWorld/entry/src/main/ets/entryability/EntryAbility.ets @@ -2,7 +2,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; import AbilityConstant from '@ohos.app.ability.AbilityConstant'; import Want from '@ohos.app.ability.Want'; import window from '@ohos.window'; -import type { BusinessError } from '@ohos.base' +import { BusinessError } from '@ohos.base' import hilog from '@ohos.hilog' class EntryAbility extends UIAbility { diff --git a/code/HelloWorld/entry/src/main/ets/pages/Index.ets b/code/HelloWorld/entry/src/main/ets/pages/Index.ets index 68bfd058974d2d3f510d3cc53adde830113f3881..2b790a2fa92e1bff21217a0475fb5f6efd3ab4a7 100644 --- a/code/HelloWorld/entry/src/main/ets/pages/Index.ets +++ b/code/HelloWorld/entry/src/main/ets/pages/Index.ets @@ -1,37 +1,44 @@ -import { Text } from "@koalaui.arkts-arkui.Text" -import { Column } from "@koalaui.arkts-arkui.Column" -import { Button } from "@koalaui.arkts-arkui.Button" -import { Component } from "@koalaui.arkts-arkui.Common" -import { UserView, UserViewBuilder } from "@koalaui.arkts-arkui.UserView" -import { __memo_context_type, __memo_id_type } from "@ohos.arkui.StateManagement.runtime" -import { memo } from "@ohos.arkui.StateManagement.runtime" +import { memo, __memo_context_type, __memo_id_type } from "@ohos.arkui.stateManagement" // should be insert by ui-plugins +import { Text, TextAttribute, Column, Component, Button, ButtonAttribute, ClickEvent, UserView } from "@ohos.arkui.component" // TextAttribute should be insert by ui-plugins +import { State, StateDecoratedVariable, MutableState, stateOf, observableProxy } from "@ohos.arkui.stateManagement" // should be insert by ui-plugins import hilog from '@ohos.hilog' @Component struct MyStateSample { + @State stateVar: string = "state var"; + message: string = "var"; + changeValue() { + this.stateVar+="~" + } build() { - Column() { - Text("Hello World!") - Button('change') + Column(undefined) { + Text("Hello World").fontSize(20) + Button(this.message).backgroundColor("#FFFF00FF") + .onClick((e: ClickEvent) => { + hilog.info(0x0000, 'testTag', 'On Click'); + this.changeValue() + }) + Text(this.stateVar).fontSize(20) + Child({stateVar: this.stateVar} as __Options_Child) } } } +@Component +struct Child { + @State stateVar: string = "Child"; + build() { + Text(this.stateVar).fontSize(50) + } +} + export class ComExampleTrivialApplication extends UserView { - getBuilder(): UserViewBuilder { - hilog.info(0x0000, 'testTag', 'ComExampleTrivialApplication'); - let wrapper = (__memo_context: __memo_context_type, __memo_id: __memo_id_type) => { - hilog.info(0x0000, 'testTag', 'MyStateSample.instantiateImpl'); - MyStateSample.instantiateImpl( - // __memo_context, - // ((__memo_id) + (21211165)), - undefined, - (): MyStateSample => new MyStateSample(), - {} as __Options_MyStateSample, - undefined - ) + getBuilder() { + hilog.info(0x0000, 'testTag', 'getBuilder'); + let wrapper = @memo () => { + hilog.info(0x0000, 'testTag', 'MyStateSample'); + MyStateSample(undefined) } - hilog.info(0x0000, 'testTag', 'getBuilder.end'); return wrapper } } \ No newline at end of file