Socket
Socket
Sign inDemoInstall

@uni/vibrate

Package Overview
Dependencies
1
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @uni/vibrate


Version published
Weekly downloads
277
decreased by-52.97%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

vibrate

npm

使手机发生振动

支持

browser miniApp wechatMiniprogram bytedanceMicroApp baiduSmartProgram

安装

$ npm install @uni/vibrate --save

or

$ npm install @uni/apis --save

示例

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');
});

你也可以从大包引入:

import { vibrate } from '@uni/apis';

vibrate.vibrateLong().then(() => {
  console.log('success');
});
vibrate.vibrateShort().then(() => {
  console.log('success');
});

方法

vibrateShort

使手机发生较短时间的振动(15 ms)。仅在 iPhone 7 / 7 Plus 以上及 Android 机型生效

参数
成员类型描述必选默认值
optionsobject ✔️-
options.successFunction 成功的回调-
options.failFunction 失败的回调-
options.completeFunction 结束的回调 (调用成功、失败都会执行)-

不通用参数(由于破坏了一码多端的能力,不推荐使用)

成员类型描述必选默认值支持度
optionsobject ✔️--
options.typestring 震动强度类型,有效值为:heavy、medium、light-wechatMiniprogram

vibrateLong

使手机发生较长时间的振动(400 ms)

参数
成员类型描述必选默认值
optionsobject ✔️-
options.successFunction 成功的回调-
options.failFunction 失败的回调-
options.completeFunction 结束的回调 (调用成功、失败都会执行)-

FAQs

Last updated on 18 Oct 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc