振动

my.vibrate(OBJECT)

调用振动功能。扫码体验:

img.jpg

代码示例

  1. Page({
  2. vibrate() {
  3. my.vibrate({
  4. success: () => {
  5. my.alert({ title: '震动起来了'});
  6. }
  7. });
  8. },
  9. })

my.vibrateLong(OBJECT)

较长时间的振动 (400ms),扫码体验:

img.jpg

代码示例

  1. Page({
  2. vibrateLong() {
  3. my.vibrateLong({
  4. success: () => {
  5. my.alert({ title: '震动起来了'});
  6. }
  7. });
  8. },
  9. })

my.vibrateShort(OBJECT)

较短时间的振动 (40ms),扫码体验:

img.jpg

代码示例

  1. Page({
  2. vibrateShort() {
  3. my.vibrateShort({
  4. success: () => {
  5. my.alert({ title: '震动起来了'});
  6. }
  7. });
  8. },
  9. })

原文: https://docs.alipay.com/mini/api/vibrate