【问题标题】:Sencha Touch 2 : Getting error while displaying simple alert message using cordovaSencha Touch 2:使用cordova显示简单警报消息时出错
【发布时间】:2013-01-02 20:19:39
【问题描述】:

BackGround:我使用 sencha 2.1 开发了一个 SenchaTouch 应用程序。现在我正在尝试使用cordova 2.2.0 js 显示一个简单的警报消息。

我的基本疑问是“我可以使用 'navigator.notification.alert' 在 google chrome 上显示警报框,还是必须在模拟器上运行它才能看到警报框?”

我已按照以下步骤操作。

  • 在我的工作区中包含了 cordova 2.2.0 js,并从 index.html 中引用了它。我可以在 Google Chrome 的网络选项卡中看到加载的文件。

  • 下面是我的代码,它只是在单击按钮时显示本机警报框。

    alertDismissed : function() {
        console.log('This function is called');
    }
    
    onLoginNoteCommand: function () {
    
        console.log('onLoginNoteCommand');
    
        navigator.notification.alert(
            'Please Select a Car',  // message
             this.alertDismissed,         // callback
             ' '            // title
         );
    }
    

发生错误

我收到“Uncaught TypeError: Cannot call method 'alert' of undefined”错误。

任何想法我做错了什么?

谢谢

【问题讨论】:

  • 简单来说这个错误说导航器对象是未定义的,因为它存在于corodova而不是sencha,尝试使用Ext.Msg

标签: cordova sencha-touch sencha-touch-2 cordova-2.0.0


【解决方案1】:

当我将我的代码与 PhoneGap 集成并在设备上运行时,我能够看到本机警报框。因此,我对上述解决方案的发现是,在将导航器对象与 PhoneGap 集成后,您只能在设备上使用导航器对象,而不能在浏览器上使用。

谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-22
    • 1970-01-01
    • 1970-01-01
    • 2020-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多