Ionic 4本机插件无法正常工作 [英] Ionic 4 native plugin not working

查看:119
本文介绍了Ionic 4本机插件无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了Ionic 4本机插件的问题.我已经安装了 ionic 4 Cordova本机插件 地理位置" ,但是当我在iOS或Android设备上运行该应用程序时,它却显示空白屏幕,但没有任何反应.

I am facing a problem with Ionic 4 native plugins. I have installed ionic 4 Cordova native plugin "Geolocation" but when I run the app into my iOS or Android device it's showing to me a blank white screen and nothing happening.

app.module.ts代码:

import {
  Geolocation
} from '@ionic-native/geolocation';
@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [
    BrowserModule,
    IonicModule.forRoot(),
    AppRoutingModule,
    ComponentsModule
  ],
  providers: [
    StatusBar,
    SplashScreen, ** Geolocation ** , {
      provide: RouteReuseStrategy,
      useClass: IonicRouteStrategy
    }
  ],
  bootstrap: [AppComponent]
})

Home.ts代码:

import {
  Geolocation
} from '@ionic-native/geolocation';
constructor(private geolocation: Geolocation) {}

我不知道为什么会这样.但是它正在处理Ionic 3项目.

任何人都可以告诉我它为什么会发生以及我做错了什么.

Anyone can give me any idea why it's happening and what I did wrong.

推荐答案

我已经找到了解决方法:

I've found the solution :

  • 打开您的 package.json 并将@ionic-native/geolocation更新为 5.0.0-beta.14 (与@ionic-native/core相同)
  • npm安装
  • 更新所有导入内容:import {Geolocation} from '@ionic-native/geolocation/ngx';(在app.module.ts和component.ts文件中)
  • open your package.json and update @ionic-native/geolocation to 5.0.0-beta.14 (same as @ionic-native/core)
  • npm install
  • update all your imports : import {Geolocation} from '@ionic-native/geolocation/ngx'; (in app.module.ts and in your component.ts file)

这篇关于Ionic 4本机插件无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆