HarmonyOS 如何获取$r('app.string.please_input_plate')中的字符串,需要字符串弹窗提示

HarmonyOS
2025-01-10 07:58:15
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
shlp

参考示例如下:

import { BusinessError } from '@kit.BasicServicesKit';

try {
  this.context.resourceManager.getStringSync($r('app.string.test').id);
} catch (error) {
  let code = (error as BusinessError).code;
  let message = (error as BusinessError).message;
  console.error(`getStringSync failed, error code: ${code}, message: ${message}.`);
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.

参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-resource-manager-V5#getstringsync9

分享
微博
QQ
微信
回复
2025-01-10 10:53:10


相关问题
HarmonyOS $r 字符串替换问题
1605浏览 • 1回复 待解决
HarmonyOS string字符串截取问题
802浏览 • 1回复 待解决
HarmonyOS string类型字符串截取
1684浏览 • 1回复 待解决
检查字符串是否以给定字符串开头
1315浏览 • 1回复 待解决
$r('xxxxx')是否支持字符串动态拼接
2865浏览 • 1回复 待解决
检查字符串是否以给定字符串结尾
1085浏览 • 1回复 待解决
字符串反射
577浏览 • 1回复 待解决
HarmonyOS 替换字符串
896浏览 • 1回复 待解决
HarmonyOS string字符串sha1加密方法
595浏览 • 1回复 待解决
HarmonyOS shortcuts配置字符串获取异常
306浏览 • 1回复 待解决
HarmonyOS 字符串显示异常
1030浏览 • 1回复 待解决
HarmonyOS字符串替换问题
1602浏览 • 1回复 待解决