Skip to main content

my.vibrate

vibrate

my.vibrate là API dùng để làm rung thiết bị, với thời gian rung 200ms.

Khả dụng: Hỗ trợ từ version 1.85.9 trở lên.

Quét mã để trải nghiệm

Xem code mẫu trên Tini Studio

API Params

Thuộc tínhKiểu dữ liệuMô tả
successFunctionCallback function khi việc rung thiết bị thành công.
failFunctionCallback function khi việc rung thiết bị thất bại.
completeFunctionCallback function việc gọi API hoàn tất bất kể thành công hay thất bại.

Sample Code

<view>
<block-header title="Usage" description="Vibrate the device" />
<view class="block-content">
<text class="title mb-8">my.vibrate</text>
<button class="button-full" onTap="onVibrate">Vibrate (200ms)</button>
</view>
</view>
Page({
onVibrate() {
my.vibrate({
fail: (e) => {
my.alert({ title: 'Fail', content: JSON.stringify(e) });
}
});
}
});