my.offCompassChange
Use this API to unlisten to the compass data.
Supported types of mini programs: DSL, H5, H5+
Sample Code
DSL
copy
my.offCompassChange();H5, H5+
copy
AlipayJSBridge.call('watchShake',{monitorCompass:true}, function(data) {
alert('Result for ' + JSON.stringify(data));
});
function compassChangehandler(res) {
alert('Result for ' + JSON.stringify(res));
}
window.document.addEventListener('compassChange', compassChangehandler)
window.document.removeEventListener('compassChange', compassChangehandler)Whether to pass callback value or not
- If the callback value is not passed, the callbacks of all events will be removed. The sample code is as follows:
copy
my.offCompassChange();- If the callback value is passed, only the corresponding callback is removed. The sample code is as follows:
copy
my.offCompassChange(this.callback);