此代码正常运行,直到升级到ionic 3.4
。
现在在服务命令显示:
属性'连接'类型' Navigator'
上不存在
我已将此代码Network.connection
替换为navigator.connection
,但结果仍然相同。
export class NetworkService {
onDevice: boolean;
constructor(public platform: Platform , private Network: Network){
this.onDevice = this.platform.is('cordova');
}
isOnline(): boolean {
if(this.onDevice && Network.connection){
return Network.connection !== Connection.NONE;
} else {
return navigator.onLine;
}
}
isOffline(): boolean {
if(this.onDevice && Network.connection){
return Network.connection === Connection.NONE;
} else {
return !navigator.onLine;
}
}
}