Kendo UI 移动应用程序,显示后查看事件无法访问 cordova 插件。外面的活动很好

KendoUI mobile app, view event afterShow has no access to cordova plugin. Outside event is fine

我有一个 kendoui applbuilder 移动应用程序。我已经安装了一个自定义的 camerapreview 插件,它工作正常。我尝试将事件处理程序添加到我的视图 (afterShow) 以在相机插件模块中设置一些内容:

cordova.plugins.camerapreview.startCamera(

初始化相机预览。

问题似乎是在此处理程序中 cordova.plugins.camerapreview 未定义?在视图上的按钮处理程序中访问相同的方法工作正常。我假设这与依赖有关?我怎样才能确保它已加载?在视图加载并绑定模型后它不可用对我来说没有意义。

我的代码如下所示:

// Handle "deviceready" event
document.addEventListener('deviceready', onDeviceReady, false);


var mobileApp = new kendo.mobile.Application(document.body, {

                                                 skin: 'flat',
                                                 initial: 'views/home.html'
                                             });

使用 Kendo UI 移动应用和 Cordova 时,确保在 deviceready 事件中初始化应用。这将确保 Cordova API 在整个应用程序生命周期内可用。

// this function is called by Cordova when the application is loaded by the device
document.addEventListener('deviceready', function () {  

  // hide the splash screen as soon as the app is ready. otherwise
  // Cordova will wait 5 very long seconds to do it for you.
  navigator.splashscreen.hide();

  app = new kendo.mobile.Application(document.body, {

    // you can change the default transition (slide, zoom or fade)
    transition: 'slide',

    // comment out the following line to get a UI which matches the look
    // and feel of the operating system
    // skin: 'flat',

    // the application needs to know which view to load first
    initial: 'views/home.html'
  });

}, false);