#鸿蒙学习大百科#如何将资源对象转成string类型?

如何将资源对象转成string类型?

HarmonyOS
2024-10-29 09:37:50
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
莫名瞄一眼
import { resourceManager } from '@kit.LocalizationKit';
import { BusinessError } from '@kit.BasicServicesKit';

try {
  let systemResourceManager = resourceManager.getSystemResourceManager();
  systemResourceManager.getStringValue($r('sys.string.ohos_lab_vibrate').id).then((value: string) => {
    console.info("sys.string.ohos_lab_vibrate value is " + value);
  }).catch((error: BusinessError) => {
    console.error(`systemResourceManager getStringValue promise error is ${JSON.stringify(error)}`);
  });
} catch (error) {
  let code = (error as BusinessError).code;
  let message = (error as BusinessError).message;
  console.error(`systemResourceManager getStringValue failed, error code: ${code}, message: ${message}.`);
}
分享
微博
QQ
微信
回复
2024-10-29 16:12:39
相关问题
如何将Resource资源对象转成string类型
2980浏览 • 1回复 待解决
如何将ArrayBuffer转成string
482浏览 • 1回复 待解决
如何将ArrayBuffer转成string
2382浏览 • 1回复 待解决