QVibration 触发设备振动
API兼容性:
QRN:v7.1.16
iOS:80011352
Android:60001671
QVibration 触发设备振动
引入
const { QVibration } = require('qunar-react-native');
API
简单振动
QVibration.vibrate({ duration: 500 });
模式振动
QVibration.vibrate({
pattern: [0, 300, 200, 300, 200, 600],
repeat: true
});
指定强度
QVibration.vibrate({
duration: 1000,
strength: 'strong'
});
使用说明
QVibration.vibrate(options: VibrationOptions)
触发设备振动
参数:
- options (VibrationOptions): 振动配置对象,包含以下属性:
- pattern (number[], 可选): 振动模式数组 [延迟, 振动时长, 延迟, 振动时长, ...] (ios振动时长不生效)
- duration (number, 可选): 单次振动时长(毫秒),默认 500ms(ios振动时长不生效)
- repeat (boolean, 可选): 是否重复模式,默认 false
- strength ('weak' | 'medium' | 'strong' | ‘verystrong', 可选): 振动强度,默认 'medium'
QVibration.cancel()
停止所有正在进行的振动