【发布时间】:2019-01-15 07:04:59
【问题描述】:
在我的 react 应用程序中,我正在尝试使用 Cordova 插件 (cordovo-plugin-device) 来获取用户的设备版本,如下所示
class LogoHeader extends React.Component {
componentDidMount () {
window.addEventListener('deviceready', this.onDeviceReady)
}
onDeviceReady () {
console.log(device.cordova)
}
render () {
...
}
}
但由于某种原因,deviceready 事件永远不会被触发。我错过了什么吗?有没有更好的方法在 react 中监听 DOM 事件?
【问题讨论】:
标签: reactjs cordova cordova-plugins react-dom