Ionic2,如何将自定义插件(appsee或uxcam)导入Ionic App [英] Ionic2, how to import custom plugin (appsee or uxcam) into Ionic App

查看:460
本文介绍了Ionic2,如何将自定义插件(appsee或uxcam)导入Ionic App的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Appsee UXcam

我尝试了如下导入,但没有运气
// import {appsee}来自'@ ionic-native / appsee';

I tried import like below, but no luck // import { Appsee } from '@ionic-native/appsee';

另外,我看到你必须声明有问题的变量来识别变量,我做了如下所示

Else where i saw that you have to declare the variable in question for typescript to recognize the variable, I did that like below

声明var cordova:any;

// 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 to构造函数,但仍然没有运气。

I've also tried adding public appsee: Appsee to the constructor but still no luck.

任何指导都表示赞赏。我收到 ReferenceError:未定义cordova。

Any guidance is appreciated. I'm getting ReferenceError: cordova is not defined.

如何导入自定义插件, appsee

How do I import a custom plugin, appsee

编辑添加建议的代码
声明var appsee:any;

edit adding suggested code declare var Appsee:any;

@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();
    });
  }
}


推荐答案

你只需要将它放在 imports 下,如下所示。

You just need to put it under the imports as shown below.

//your other imports here

declare var Appsee:any;

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

这篇关于Ionic2,如何将自定义插件(appsee或uxcam)导入Ionic App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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