提交 8834b47f 编写于 作者: C cff-gite

修改了sensor和vibrate的用例格式、参数、命名错误。

Signed-off-by: Ncff-gite <chenfeifei8@huawei.com>
上级 9b03f4a8
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## 导入模块 ## 导入模块
``` ```
import vibrate from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
``` ```
...@@ -16,7 +16,7 @@ import vibrate from '@ohos.vibrator'; ...@@ -16,7 +16,7 @@ import vibrate from '@ohos.vibrator';
ohos.permission.VIBRATE ohos.permission.VIBRATE
## vibrate.vibrate ## vibrator.vibrate
vibrate(duration: number): Promise&lt;void&gt; vibrate(duration: number): Promise&lt;void&gt;
...@@ -37,17 +37,15 @@ vibrate(duration: number): Promise&lt;void&gt; ...@@ -37,17 +37,15 @@ vibrate(duration: number): Promise&lt;void&gt;
- 示例: - 示例:
``` ```
vibrator.vibrate(1000).then(error)=>{ vibrator.vibrate(1000).then(()=>{
if(error){ console.log("Promise returned to indicate a successful vibration.");
console.log(“error.code”+error.code+“error.message”+error.message); }, (error)=>{
}else{ console.log("error.code"+error.code+"error.message"+error.message);
console.log(“Promise returned to indicate a successful vibration.”); });
}
}
``` ```
## vibrate.vibrate ## vibrator.vibrate
vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void
...@@ -63,15 +61,15 @@ vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void ...@@ -63,15 +61,15 @@ vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void
``` ```
vibrator.vibrate(1000,function(error){ vibrator.vibrate(1000,function(error){
if(error){ if(error){
console.log(“error.code”+error.code+“error.message”+error.message); console.log("error.code"+error.code+"error.message"+error.message);
}else{ }else{
console.log(“Callback returned to indicate a successful vibration.”); console.log("Callback returned to indicate a successful vibration.");
} }
}) })
``` ```
## vibrate.vibrate ## vibrator.vibrate
vibrate(effectId: EffectId): Promise&lt;void&gt; vibrate(effectId: EffectId): Promise&lt;void&gt;
...@@ -89,17 +87,15 @@ vibrate(effectId: EffectId): Promise&lt;void&gt; ...@@ -89,17 +87,15 @@ vibrate(effectId: EffectId): Promise&lt;void&gt;
- 示例: - 示例:
``` ```
vibrator.vibrate(effectId:EffectId).then(error)=>{ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{
if(error){ console.log("Promise returned to indicate a successful vibration.");
console.log(“error.code”+error.code+“error.message”+error.message); }, (error)=>{
}else{ console.log("error.code"+error.code+"error.message"+error.message);
Console.log(“Promise returned to indicate a successful vibration.”); });
}
}
``` ```
## vibrate.vibrate ## vibrator.vibrate
vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void
...@@ -113,17 +109,17 @@ vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void ...@@ -113,17 +109,17 @@ vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void
- 示例: - 示例:
``` ```
vibrator.vibrate(effectId:EffectId,function(error){ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){
if(error){ if(error){
console.log(“error.code”+error.code+“error.message”+error.message); console.log("error.code"+error.code+"error.message"+error.message);
}else{ }else{
console.log(“Callback returned to indicate a successful vibration.”); console.log("Callback returned to indicate a successful vibration.");
} }
}) })
``` ```
## vibrate.stop ## vibrator.stop
stop(stopMode: VibratorStopMode): Promise&lt;void&gt; stop(stopMode: VibratorStopMode): Promise&lt;void&gt;
...@@ -141,17 +137,15 @@ stop(stopMode: VibratorStopMode): Promise&lt;void&gt; ...@@ -141,17 +137,15 @@ stop(stopMode: VibratorStopMode): Promise&lt;void&gt;
- 示例: - 示例:
``` ```
vibrator.stop(stopMode:VibratorStopMode).then((error)=>{ vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{
if(error){ console.log("Promise returned to indicate a successful vibration.");
console.log(“error.code”+error.code+“error.message”+error.message); }, (error)=>{
}else{ console.log("error.code"+error.code+"error.message"+error.message);
Console.log(“Promise returned to indicate successful.”); });
}
})
``` ```
## vibrate.stop ## vibrator.stop
stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void; stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void;
...@@ -165,11 +159,11 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void; ...@@ -165,11 +159,11 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void;
- 示例: - 示例:
``` ```
vibrator.stop(stopMode:VibratorStopMode,function(error){ vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){
if(error){ if(error){
console.log(“error.code”+error.code+“error.message”+error.message); console.log("error.code"+error.code+"error.message"+error.message);
}else{ }else{
Console.log(“Callback returned to indicate successful.”); console.log("Callback returned to indicate successful.");
} }
}) })
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册