当应用程序第一次启动时,这是工作的,然后从会话中删除应用程序,然后启动应用程序,它说。
未定义IRoot
declare var IRoot: any;
ngOnInit() {
this._platform.ready().then(() => {
if (typeof (IRoot) !== 'undefined' && IRoot) {
IRoot.isRooted((data) => {
if (data && data == 1) {
this.isRootedORJailBreak = true
console.log("*******This is routed device");
} else {
this.isRootedORJailBreak = false
console.log("*******This is not routed device");
}
}, (data) => {
this.isRootedORJailBreak = false
console.log("*******routed device detection failed case", data);
});
});
} }发布于 2018-05-14 14:11:35
当cordova准备好时,插件似乎还没有准备好,或者没有及时注册。
您可以尝试用一个plataform.ready()包装您的代码,看看它是否有效。
我在github上看到了你的问题和他们给你的回应,但是和你在这里试过的一样。
更新
将this._platform.ready().then(() => {})块中的代码移动到ionViewDidEnter钩子中,ngOnInit的问题是可以缓存它,并且只会调用一次,ionViewDidEnter将始终被调用,如果之前已经初始化了组件,则不存在任何问题。
这个问题似乎是缓存的问题。
发布于 2018-05-01 03:33:05
删除(IRoute)周围的括号,因为它将首先评估typeof (IRoute)之前的括号内容。
尽管如此,IRout仍将是未定义的,您需要在未定义它时采取行动。
如果是远程库,则触发onload事件,以便在需要的地方等待加载。
https://stackoverflow.com/questions/50098970
复制相似问题