1.0.1 • Published 4 years ago
@uni/vibrate v1.0.1
vibrate
Make the phone vibrate
Supported
Install
$ npm install @uni/vibrate --save
or
$ npm install @uni/apis --save
Usage
import { vibrateShort } from '@uni/vibrate';
vibrateLong({
success (){
console.log('success');
}
});
// promise
vibrateLong().then(() => {
console.log('success');
});
vibrateShort({
success (){
console.log('success');
}
});
// promise
vibrateShort().then(() => {
console.log('success');
});
You can also import from the big package:
import { vibrate } from '@uni/apis';
vibrate.vibrateLong().then(() => {
console.log('success');
});
vibrate.vibrateShort().then(() => {
console.log('success');
});
方法
vibrateShort
Allows the phone to vibrate for a short period of time (15 ms). This only works on iPhone 7/7 Plus and Android models.
Arguments
Property | Type | Description | required | Default |
---|---|---|---|---|
options | object | ✔️ | - | |
options.success | Function | The callback function for a successful API call | ✘ | - |
options.fail | Function | The callback function for a failed API call | ✘ | - |
options.complete | Function | The callback function used when the API call completed (always executed whether the call succeeds or fails) | ✘ | - |
Non-universal parameters (due to destroying the ability of one code and multiple terminals, it is not recommended to use)
Property | Type | Description | required | Default | Supported |
---|---|---|---|---|---|
options | object | ✔️ | - | - | |
options.type | string | Vibration intensity type, valid values are: heavy, medium, light | ✘ | - |
vibrateLong
Allows the phone to vibrate for a long period of time (400 ms).
Arguments
Property | Type | Description | required | Default |
---|---|---|---|---|
options | object | ✔️ | - | |
options.success | Function | The callback function for a successful API call | ✘ | - |
options.fail | Function | The callback function for a failed API call | ✘ | - |
options.complete | Function | The callback function used when the API call completed (always executed whether the call succeeds or fails) | ✘ | - |