我想使用meteor/cordova在iPhone上顯示當前的電池電量並作出反應。使用meteor/cordova顯示電池電量並作出反應
This是我使用的插件。
這是我想象它的工作:
export default class BatteryDetails extends Component {
constructor(props){
super(props);
this.currentBatteryLevel = 0;
function onBatteryStatus(status) {
this.currentBatteryLevel = status.level;
}
window.addEventListener("batterystatus", onBatteryStatus, false);
window.dispatchEvent(new Event('batterystatus'));
}
render() {
return (
<div>
Remaining: {this.currentBatteryLevel}
</div>
);
}
}
在你的'render'方法中,你試圖呈現'this.getBatteryLevel()' - 但是,它看起來像這個函數不會返回任何值。 – cathalkilleen