All Products
Search
Document Center

Shake

Last Updated: Feb 04, 2021

my.watchShake(OBJECT)

Note: This interface is only supported in mPaaS 10.1.32 and later versions.

This interface is used for the shake function. Each time the API is called, the callback will be triggered after shaking the phone. If you need to listen to it again, call this API again.

Sample code

 
  1. // API-DEMO page/API/watch-shake/watch-shake.json
  2. {
  3. "defaultTitle": "Shake"
  4. }
 
  1. <!-- API-DEMO page/API/watch-shake/watch-shake.axml-->
  2. <view class="page">
  3. <button type="primary" onTap="watchShake">
  4. Bind the shake function, and click the Shake button to view the effect
  5. </button>
  6. </view>
 
  1. // API-DEMO page/API/watch-shake/watch-shake.js
  2. Page({
  3. watchShake() {
  4. my.watchShake({
  5. success: function() {
  6. console.log('It moved')
  7. my.alert({ title:'It moved o.o'});
  8. }
  9. });
  10. },
  11. });