diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 28412bb767908ba160b464c172ae70e81911bcb1..48384ef0cd9117390e597cc4dd46d87fca7af64f 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -36,7 +36,7 @@ struct Index { .fontSize(16) .width('100%') .onClick(() => { - promptAction.showToast({ message: 'Native method call succeed, result is ' + napi.add(2, 3).toString() }); + this.getUIContext().getPromptAction().showToast({ message: 'Native method call succeed, result is ' + napi.add(2, 3).toString() }); }) Button($r('app.string.call_har_native_method')) @@ -44,7 +44,7 @@ struct Index { .width('100%') .margin({ top: 12 }) .onClick(() => { - promptAction.showToast({ + this.getUIContext().getPromptAction().showToast({ message: 'HarNative method call succeed, result is ' + napi.invokeHarNative(2, 3).toString() }); }) @@ -54,7 +54,7 @@ struct Index { .width('100%') .margin({ top: 12 }) .onClick(() => { - promptAction.showToast({ message: 'HarArkTS method call succeed, result is ' + this.getUIContext().getPromptAction().showToast({ message: 'HarArkTS method call succeed, result is ' + napi.invokeHarArkTS(2, 3).toString() }); }) @@ -63,7 +63,7 @@ struct Index { .width('100%') .margin({ top: 12 }) .onClick(() => { - promptAction.showToast({ + this.getUIContext().getPromptAction().showToast({ message: 'HspNative method call succeed, result is ' + napi.invokeHspNative(2, 3).toString() }); }) @@ -73,7 +73,7 @@ struct Index { .width('100%') .margin({ top: 12 }) .onClick(() => { - promptAction.showToast({ message: 'HspArkTS method call succeed, result is ' + this.getUIContext().getPromptAction().showToast({ message: 'HspArkTS method call succeed, result is ' + napi.invokeHspArkTS(2, 3).toString() }); }) }