my.watchShake
The watchshake function. Every time this API is called, a callback is triggered after the mobile phone is shaken. You must call this API again to continue to listen to this event.
Sample Code
copy
// API-DEMO page/API/watch-shake/watch-shake.json
{
"defaultTitle": "Shake"
}
copy
<!-- API-DEMO page/API/watch-shake/watch-shake.axml-->
<view class="page">
<button type="primary" onTap="watchShake">
Bind the shake function and click the shake button to see the effect.
</button>
</view>
copy
// API-DEMO page/API/watch-shake/watch-shake.js
Page({
watchShake() {
my.watchShake({
success: function() {
console.log('It moved')
my.alert({ title:'It moved o.o'});
}
});
},
});