【问题标题】:Ionic2, how to import custom plugin (appsee or uxcam) into Ionic AppIonic2,如何将自定义插件(appsee 或 uxcam)导入 Ionic App
【发布时间】:2018-05-18 14:34:57
【问题描述】:

我正在尝试使用AppseeUXcam

我尝试如下导入,但没有运气 // 从 '@ionic-native/appsee' 导入 { Appsee };

在其他地方我看到你必须声明有问题的变量才能让打字稿识别变量,我在下面这样做了

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

我也尝试将 public appsee: Appsee 添加到构造函数中,但仍然没有成功。

感谢任何指导。我收到 ReferenceError: cordova is not defined.

如何导入自定义插件,appsee

编辑添加建议的代码 声明 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();
    });
  }
}

【问题讨论】:

    标签: angular ionic2 cordova-plugins ionic3 uxcam


    【解决方案1】:

    您只需将其放在imports 下,如下所示。

    //your other imports here
    
    declare var Appsee:any;
    
    @Component({
      templateUrl: 'app.html'
    })
    export class MyApp {
      @ViewChild(Nav) nav: Nav;
    

    【讨论】:

    • 感谢您的回复。将该语句放在我的 app.module.ts 或 app.components.ts 中?我尝试在 module.ts 文件中的导入下执行它,这给了我错误当我将该语句放在 component.ts 文件的构造函数上方时,我得到一个引用错误...
    • 你需要把你使用它的地方放好。看来您在app.components.ts 内使用。所以放在那里。把它放在import下面。
    • 查看我编辑的代码,如果正确,我仍然收到参考错误
    • 是的,我最初尝试过,但仍然出现引用错误(appsee 未定义)
    • 你运行过这个ionic cordova plugin add cordova-plugin-appsee --save
    猜你喜欢
    • 2021-07-25
    • 2021-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多