diff --git a/README.en.md b/README.en.md index 7895fcaa6957ffa97c5a1a248c6ead88eba45083..7c3fc0cc84c57a9c50cbc898908d69c7d3450097 100644 --- a/README.en.md +++ b/README.en.md @@ -1,4 +1,4 @@ -# Implementing Fixed-Style and Custom Dialog Boxes +# Implement various pop-up window functions based on ArkUI ## Overview This sample describes how to add custom dialog boxes and the following fixed-style dialog boxes to an application: popup, toast, date picker, text picker, and alert dialog boxes. You can use the system APIs to pass in related parameters to implement fixed-style dialog boxes. For custom dialog boxes, you can define the style and interaction mode to handle more complex scenarios. diff --git a/README.md b/README.md index eef6c9d0a5e355daa7def609c73ae9edc88d6115..c75da5481d022307971c649ac39e6266b98aa3d4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 实现固定样式和自定义样式弹窗 +# 基于ArkUI实现多种样式弹窗功能 ## 简介 diff --git a/entry/src/main/ets/utils/CommonUtils.ets b/entry/src/main/ets/utils/CommonUtils.ets index 993030320f8824305859eed94ecf3fbf83fff9e4..78973fdca349cc2d4b81aaee2953c88880bc484f 100644 --- a/entry/src/main/ets/utils/CommonUtils.ets +++ b/entry/src/main/ets/utils/CommonUtils.ets @@ -12,6 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { hilog } from "@kit.PerformanceAnalysisKit"; +import { BusinessError } from "@kit.BasicServicesKit"; class HobbyItem { label?: string; @@ -23,10 +25,19 @@ const context = uiContext?.getHostContext(); export class CommonUtils { getBirthDateValue(year: number, month: number, day: number): string { - let resourceYear = context?.resourceManager.getStringSync($r('app.string.year')); - let resourceMonth = context?.resourceManager.getStringSync($r('app.string.month')); - let resourceDay = context?.resourceManager.getStringSync($r('app.string.day')); - let birthdate: string = `${year}${resourceYear}${month}` + `${resourceMonth}${day}${resourceDay}`; + let resourceYear: string | undefined = ''; + let resourceMonth: string | undefined = ''; + let resourceDay: string | undefined = ''; + let birthdate: string | undefined = ''; + try { + resourceYear = context?.resourceManager.getStringSync($r('app.string.year').id); + resourceMonth = context?.resourceManager.getStringSync($r('app.string.month').id); + resourceDay = context?.resourceManager.getStringSync($r('app.string.day').id); + birthdate = `${year}${resourceYear}${month}` + `${resourceMonth}${day}${resourceDay}`; + } catch (error) { + let err = error as BusinessError; + hilog.error(0x0000, '', `getStringSync failed. code=${err.code},message=${err.message}`); + } return birthdate; }