2017-12-05 6 views
1

は、私は以下のようなインポートを試していないが、「から運 //インポート{Appsee} @ionic - ネイティブ/ appsee ';私はあなたが変数を認識するtypescriptですために、問題の変数を宣言しなければならないことを見たそうでIonic2、イオンアプリにカスタムプラグイン(appseeまたはuxcam)をインポートする方法

、私がやったような

以下の宣言のvarコルドバ:任意の;

// import { Appsee } from '@ionic-native/appsee'; 

declare var cordova:any; 

@Component({ 
    templateUrl: 'app.html' 
}) 
export class MyApp { 

    rootPage:any = LoginPage;  // FOR TESTING 

    constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { 
    platform.ready().then(() => { 
    cordova.plugins.Appsee.start("my key"); 

     // Okay, so the platform is ready and our plugins are available. 
     // Here you can do any higher level native things you might need. 
     statusBar.styleDefault(); 
     splashScreen.hide(); 
    }); 
    } 
} 

私はまた、公共appsee追加しようとしました:コンストラクタが、まだ運にAppseeを。

ご了承ください。私は得ているReferenceError:cordovaは定義されていません。私は、カスタムプラグイン、提案されたコードに 宣言VAR Appsee追加appsee

編集インポートするにはどうすればよい

:いずれかを。

@Component({ 
    templateUrl: 'app.html' 
}) 
export class MyApp { 
    rootPage:any = LoginPage;  // FOR TESTING 

    constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { 
    platform.ready().then(() => { 
    Appsee.start("my key"); 

     // Okay, so the platform is ready and our plugins are available. 
     // Here you can do any higher level native things you might need. 
     statusBar.styleDefault(); 
     splashScreen.hide(); 
    }); 
    } 
} 

答えて

0

以下に示すように、importsの下に置くだけです。

//your other imports here 

declare var Appsee:any; 

@Component({ 
    templateUrl: 'app.html' 
}) 
export class MyApp { 
    @ViewChild(Nav) nav: Nav; 
+0

返信ありがとうございます。そのステートメントを私のapp.module.tsまたはapp.components.tsに配置しますか?私はmodule.tsファイルのインポートの下でそれをやろうとしましたが、私にエラーが発生します この文をcomponent.tsファイルのコンストラクタの上に置くと、参照エラーが発生します... – Generaldeep

+0

あなたは場所を置く必要がありますどこでそれを使うのですか?あなたが 'app.components.ts'の中で使っているようです。だからそこに置く。 'import'の直下に置いてください。 – Sampath

+0

私の編集したコードを見て、それが正しい場合、私はまだ参照エラーを得ています – Generaldeep

関連する問題