PhoneGap - 已调用电池状态但状态未定义
PhoneGap - batterystatus called but status undefined
Cordova (PhoneGap) - 调用了 batterystatus-callback,但根据 logg,status 和 isplugged 都是 undefined
可能是什么原因?
onDeviceReady: function() {
//alert('deviceready!!!!!!!!');
d.lg('device ready :-)');
window.addEventListener('batterystatus', app.batteryListener, false);
app.receivedEvent('deviceready');
},
batteryListener: function() {
//alert("batterylistener!");
console.log("Level: " + status.level + " isPlugged: " + status.isPlugged);
}
logcatAndroidStudio
2019-04-05 15:38:36.039 17689-17689/com.phonegap.app D/SystemWebChromeClient: file:///android_asset/www/js/app.js: Line 93 : Level: undefined isPlugged: undefined
2019-04-05 15:38:36.039 17689-17689/com.phonegap.app I/chromium: [INFO:CONSOLE(93)] "Level: undefined isPlugged: undefined", source: file:///android_asset/www/js/app.js (93)
那是因为您的 batterListener
方法缺少 status
。
batteryListener: function(status) {
Cordova (PhoneGap) - 调用了 batterystatus-callback,但根据 logg,status 和 isplugged 都是 undefined
可能是什么原因?
onDeviceReady: function() {
//alert('deviceready!!!!!!!!');
d.lg('device ready :-)');
window.addEventListener('batterystatus', app.batteryListener, false);
app.receivedEvent('deviceready');
},
batteryListener: function() {
//alert("batterylistener!");
console.log("Level: " + status.level + " isPlugged: " + status.isPlugged);
}
logcatAndroidStudio
2019-04-05 15:38:36.039 17689-17689/com.phonegap.app D/SystemWebChromeClient: file:///android_asset/www/js/app.js: Line 93 : Level: undefined isPlugged: undefined
2019-04-05 15:38:36.039 17689-17689/com.phonegap.app I/chromium: [INFO:CONSOLE(93)] "Level: undefined isPlugged: undefined", source: file:///android_asset/www/js/app.js (93)
那是因为您的 batterListener
方法缺少 status
。
batteryListener: function(status) {