0

运行 ionic serve 时,我从本机导入的每个项目中都收到 Typescript 错误。这是在我更新到 ionic-native v3 之后。Typescript 无法识别来自新 @ionic-native 的所有项目。我将打字稿更新为不同的 v2 版本,但无法正常工作。

我没有更改任何其他代码。它不仅与 SplashScreen 有关。我对过去通过“ionic-native”(旧样式)导入的对象以及现在通过@ionic-native/{plugin-name} 导入的对象的所有引用都给出了这些 Typescript 错误。

有人可以帮忙吗?目前无法提供或构建我的应用

例如:

property hide does not exist on type typeof SplashScreen

我将导入更改为

import { LocalNotifications } from '@ionic-native/local-notifications';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

我的离子信息:

 ordova CLI: 6.5.0
Ionic Framework Version: 2.2.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v7.0.0
Xcode version: Not installed

我的离子插件 ls

cordova-plugin-app-event 1.2.0 "Application Events"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-camera 2.4.0 "Camera"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.6 "Console"
cordova-plugin-device 1.1.5 "Device"
cordova-plugin-fcm 2.1.1 "FCMPlugin"
cordova-plugin-nativestorage 2.2.1 "NativeStorage"
cordova-plugin-splashscreen 4.0.2 "Splashscreen"
cordova-plugin-statusbar 2.2.2 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
cordova-plugin-x-socialsharing 5.1.6 "SocialSharing"
de.appplant.cordova.plugin.local-notification 0.8.4 "LocalNotification"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-barcodescanner 6.0.5 "BarcodeScanner"

我的 package.json

"dependencies": {
    "@angular/common": "2.4.8",
    "@angular/compiler": "2.4.8",
    "@angular/compiler-cli": "2.4.8",
    "@angular/core": "2.4.8",
    "@angular/forms": "2.4.8",
    "@angular/http": "2.4.8",
    "@angular/platform-browser": "2.4.8",
    "@angular/platform-browser-dynamic": "2.4.8",
    "@angular/platform-server": "2.4.8",
    "@ionic/storage": "2.0.0",
    "@ionic-native/core": "^3.1.0",
    "ionicons": "3.0.0",
    "ionic-angular": "2.2.0",
    "rxjs": "5.0.1",
    "zone.js": "0.7.2",
    "sw-toolbox": "3.5.1",
    "babel-core": "^6.24.0",
    "d": "^1.0.0",
    "ng2-translate": "^4.0.0",
    "@ionic-native/barcode-scanner": "^3.1.0",
    "@ionic-native/local-notifications": "^3.1.0",
    "@ionic-native/native-storage": "^3.1.0",
    "@ionic-native/social-sharing": "^3.1.0",
    "@ionic-native/splash-screen": "^3.1.0",
    "@ionic-native/status-bar": "^3.1.0"

  },
  "devDependencies": {
    "@ionic/app-scripts": "^1.1.4",
    "@ionic/cli-build-ionic-angular": "0.0.3",
    "@ionic/cli-plugin-cordova": "0.0.9",
    "typescript": "2.0.9"
  }

tsc -v

Version 2.2.1
4

1 回答 1

2

根据此处更新的文档,您需要在构造函数中注入 Splashscreen。

constructor(private splashScreen: SplashScreen) { }
this.splashscreen.hide();

在以前的版本中,您将使用Splashscreen直接导入的方法来调用方法。

于 2017-03-22T08:37:32.207 回答