中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
如何将资源对象转成string类型?
微信扫码分享
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}.`); }