From 1e3cbba7bd0cd2d37d3632f2b90f34e5512e0361 Mon Sep 17 00:00:00 2001 From: liugang9704 <2745340733@qq.com> Date: Tue, 19 Aug 2025 19:14:05 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E8=AD=A6=E5=91=8A=E6=B8=85=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 14 ++++++++++---- entry/src/main/ets/view/IconView.ets | 24 ++++++++++++++++++------ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 76660e6..c6a993d 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { promptAction } from '@kit.ArkUI'; import { StackConstant } from '../constant/StackConstant'; import { IconList1, IconList2, IconList3 } from '../view/IconView'; import { ProductList } from '../view/ProductList'; @@ -72,8 +71,14 @@ struct Index { .height(this.searchHeight) .backgroundColor(Color.White) .borderRadius($r('app.integer.search_border_radius')) - .onClick(()=>{ - this.getUIContext().getPromptAction().showToast({ message: $r('app.string.component_stack_other_function')}); + .onClick(() => { + try { + this.getUIContext() + .getPromptAction() + .showToast({ message: $r('app.string.component_stack_other_function') }); + } catch (error) { + console.error(`showToast args error code is ${error.code}, message is ${error.message}`); + } }); Stack({ alignContent: Alignment.Top }) { @@ -106,7 +111,8 @@ struct Index { ProductList() .width(StackConstant.FULL_PERCENT) - .height(this.getUIContext().px2vp(this.screenHeight - this.statusHeight - this.bottomHeight) - StackConstant.USED_SPACE) + .height(this.getUIContext().px2vp(this.screenHeight - this.statusHeight - this.bottomHeight) - + StackConstant.USED_SPACE) } .margin({ top: StackConstant.MARGIN_TOP }) } diff --git a/entry/src/main/ets/view/IconView.ets b/entry/src/main/ets/view/IconView.ets index f193aed..8330ee2 100644 --- a/entry/src/main/ets/view/IconView.ets +++ b/entry/src/main/ets/view/IconView.ets @@ -41,8 +41,12 @@ struct IconView1 { .justifyContent(FlexAlign.Center) .backgroundColor(Color.White) .borderRadius($r('app.integer.icon_view_border_radius')) - .onClick(()=>{ - this.getUIContext().getPromptAction().showToast({ message: $r('app.string.component_stack_other_function')}); + .onClick(() => { + try { + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.component_stack_other_function') }); + } catch (error) { + console.error(`showToast args error code is ${error.code}, message is ${error.message}`); + } }) } } @@ -70,8 +74,12 @@ struct IconView2 { .justifyContent(FlexAlign.Center) .backgroundColor(Color.White) .borderRadius($r('app.integer.icon_view_border_radius')) - .onClick(()=>{ - this.getUIContext().getPromptAction().showToast({ message: $r('app.string.component_stack_other_function')}); + .onClick(() => { + try { + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.component_stack_other_function') }); + } catch (error) { + console.error(`showToast args error code is ${error.code}, message is ${error.message}`); + } }) } } @@ -97,8 +105,12 @@ struct IconView3 { .width(StackConstant.FULL_PERCENT) .height($r('app.integer.icon_view_height3')) .justifyContent(FlexAlign.Center) - .onClick(()=>{ - this.getUIContext().getPromptAction().showToast({ message: $r('app.string.component_stack_other_function')}); + .onClick(() => { + try { + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.component_stack_other_function') }); + } catch (error) { + console.error(`showToast args error code is ${error.code}, message is ${error.message}`); + } }) } } -- Gitee