1# SensorService Kit变更说明 2 3## cl.sensors.1 vibrator VibratePreset的count属性由必选变更为可选 4 5**访问级别** 6 7公开接口 8 9**变更原因** 10 11VibratePreset中的振动次数参数count作为必选参数,即使设为1也必须要填写,对于开发者使用不便。 12 13**变更影响** 14 15该变更为不兼容性变更。 16 17变更前:VibratePreset中的属性count为必选属性,必须设置。 18 19```ts 20interface VibratePreset { 21 type: 'preset'; 22 effectId: string; 23 count: number; 24} 25``` 26 27变更后:VibratePreset中的属性count变更为可选属性,默认值为1。 28 29```ts 30interface VibratePreset { 31 type: 'preset'; 32 effectId: string; 33 count?: number; 34} 35``` 36 37**起始API Level** 38 399 40 41**变更发生版本** 42 43从OpenHarmony SDK 5.0.0.27开始。 44 45**变更的接口** 46 47@ohos.vibrator.d.ts中VibratePreset的属性count。 48 49**适配指导** 50 51VibratePreset中的效果振动次数属性count变更为可选参数,如果开发者对该属性的类型存在依赖,需进行适配。比如, 52 53变更前:count的类型为number。 54 55变更后:count的类型为number | undefined。 56 57```ts 58let effect: VibratePreset = { 59 type: 'preset', 60 effectId: 'xxx', 61 count: 2 62}; 63 64let count: number | undefined = effect.count; 65``` 66