【问题标题】:Cannot call method 'getWindowHeight' of undefined after sencha build packagesencha构建包后无法调用未定义的方法'getWindowHeight'
【发布时间】:2013-04-01 07:11:20
【问题描述】:

我开发了一个应用程序,它需要根据设备的高度和宽度绘制一些容器,所以我使用了

[Ext.Viewport.getWindowHeight()][1] &     
Ext.Viewport.getWindowWidth() 

在我的代码中的几个地方,它工作正常,直到我做了sencha app build package。当我尝试打开打包的应用程序时,出现此错误:

Uncaught TypeError: Cannot call method 'getWindowHeight' of undefined       app.js:1 (anonymous function)

过去在 Sencha 论坛中提出了类似的问题,但没有得到答复: http://www.sencha.com/forum/showthread.php?240494-Call-method-getWindowHeight-of-undefined

根据 Sencha 文档:Ext.Viewport 是使用 Ext.setup 时创建的实例如果使用 Ext.onReady,则不会创建 Ext.Viewport 这个实例。但在我的 app.js 中,我使用的是 Ext.application() 而不是 Ext.setupExt.onReady

这是未创建单例的原因吗?如果是,我该如何解决?

我正在使用 Sencha Cmd Ver 3.0.2.288 & Sencha Touch ver 2.1.1

【问题讨论】:

  • 不知道为什么你认为你会在这里得到不同的答案...同样的人在这个论坛上作为煎茶一号..??
  • 希望是一件好事,也许是最好的东西,没有一件好事会死去

标签: sencha-touch sencha-touch-2 sencha-touch-2.1 sencha-cmd


【解决方案1】:

我对这个问题的解决方案是使用低级 javascript 而不是 Sencha 的框架。

如此处所述: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow

在我的情况下,使用

window.innerHeight

足够了,因为我的用户不会使用 IE。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-16
    • 2013-09-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多