小程序中使用振动
我需要在页面中提醒用户,振动是一个手段。
在小程序中支持使手机振动,可用于一些特殊场景,例如提醒用户重要事件。目前支持长时间振动(400ms)和短时间振动(15ms)两种类型。
- 长时间振动
wx.vibrateLong({
success:function(res){
console.log(res)
},
fail:function(err){
console.error(err)
}
})
- 短时间振动
wx.vibrateShort({
type:'medium',
success:function(res){
console.log(res)
},
fail:function(err){
console.error(err)
}
})