0

我有一个 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'
                                             });
4

1 回答 1

1

在 Cordova 中使用 Kendo UI Mobile 应用程序时,请确保在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);
于 2015-03-12T07:17:10.543 回答