From e3012776ebf57775e2078f752edc6af9b0c43743 Mon Sep 17 00:00:00 2001 From: lixiangpeng5 Date: Thu, 8 Jun 2023 11:36:29 +0000 Subject: [PATCH] fix code space Signed-off-by: lixiangpeng5 Change-Id: Ib2dddacb47ad221eb4c1b5e60ee1151d6d134ece --- .../device/vibrator-guidelines.md | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/zh-cn/application-dev/device/vibrator-guidelines.md b/zh-cn/application-dev/device/vibrator-guidelines.md index 637b6ccf37..8bd01f183b 100644 --- a/zh-cn/application-dev/device/vibrator-guidelines.md +++ b/zh-cn/application-dev/device/vibrator-guidelines.md @@ -254,12 +254,12 @@ Json共包含2个属性。"MetaData":文件头信息,可在相应属性中 6. 启动和停止自定义振动 ```js - import vibrator from '@ohos.vibrator'; - import resourceManager from '@ohos.resourceManager'; + import vibrator from '@ohos.vibrator'; + import resourceManager from '@ohos.resourceManager'; - const FILE_NAME = "xxx.json"; + const FILE_NAME = "xxx.json"; - async function openResource(fileName) { + async function openResource(fileName) { let fileDescriptor = undefined; let mgr = await resourceManager.getResourceManager(); await mgr.getRawFd(fileName).then(value => { @@ -269,21 +269,21 @@ Json共包含2个属性。"MetaData":文件头信息,可在相应属性中 console.log('openResource err: ' + error); }); return fileDescriptor; - } + } - async function closeResource(fileName) { + async function closeResource(fileName) { let mgr = await resourceManager.getResourceManager(); await mgr.closeRawFd(fileName).then(()=> { console.log('closeResource success fileName: ' + fileName); }).catch(error => { console.log('closeResource err: ' + error); }); - } + } - // 获取振动文件资源描述符 - let rawFd = openResource(FILE_NAME); - // 使用startVibration、stopVibration需要添加ohos.permission.VIBRATE权限 - try { + // 获取振动文件资源描述符 + let rawFd = openResource(FILE_NAME); + // 使用startVibration、stopVibration需要添加ohos.permission.VIBRATE权限 + try { // 启动自定义振动 vibrator.startVibration({ type: "file", @@ -303,11 +303,11 @@ Json共包含2个属性。"MetaData":文件头信息,可在相应属性中 } console.log('Callback returned to indicate successful.'); }) - } catch (error) { + } catch (error) { console.info('errCode: ' + error.code + ' ,msg: ' + error.message); - } - // 关闭振动文件资源 - closeResource(FILE_NAME); + } + // 关闭振动文件资源 + closeResource(FILE_NAME); ``` ## 相关实例 -- GitLab