creator h5 手机振动


creator h5 手机振动

代码:

1
2
3
4
5
6
7
8
9
10
11
supportsVibrate() {//判断手机是否支持
return "vibrate" in navigator;
},
startVibrate(duration = 1) {
if (navigator.vibrate) {
//vibrate 1 second
navigator.vibrate(duration);
} else if (navigator.webkitVibrate) {
navigator.webkitVibrate(duration);
}
},