2013-02-28 36 views
0

我在我的應用程序中使用應用程序級別全局變量,它們在iOS上正常工作。在Android上,我收到以下錯誤:無法讀取未定義的屬性baseFetchUrl應用程序級別變量在Sencha Touch 2中導致Android上的未定義錯誤

有沒有人有任何建議,爲什麼會發生這種情況?

Ext.application({ 
    name: 'MyApp', 

    //Development URLs 
    baseFetchUrl: 'http://xxxx', 
    baseStoreUrl: 'http://xxxx', 
    rootApiUrl: 'http://xxxx', 
+0

您能告訴我們何時以及如何嘗試讀取baseFetchUrl屬性嗎? – 2013-02-28 22:40:51

+0

我正在訪問它,就像在商店代理中一樣獲取像這樣的列表:'url:MyApp.app.baseFetchUrl' – 2013-03-01 20:32:48

回答

2

我遇到了同樣的問題 - W/O得到解決(我認爲它有某事做與塞納克的包裝方法,也許包裝過程打亂定義的順序,以便將爲此「 basFetchUrl「尚未定義)。可能最好的方法是創建一個外部配置文件。例如:

Ext.define('AppName.Config', { 
    singleton : true, 

    config : { 
     urls : { 
      baseUrl  : 'http://domain.de/file.php', 
      superUrl : 'http://domain.de/files.php' 
     }, 
    }, 
    constructor: function(config) { // with this you create kind of object, simple said 
     this.initConfig(config); 
     return this; 
    } 
}); 

在你app.js添加/擴展與

requires: [ 
'AppName.Config' // make sencha loading the file 
] 

現在你可以進入電影這些數據的url,如:

AppName.Config.getUrls().baseUrl 

或者您可以使用(不推薦)AppName.Config.config.urls.baseUrl(如果我們忘記啓動構造函數,則需要)

H這有助於(PS。在發送我的評論之前,我應該明確地做一些拼寫檢查,否則我必須做很多編輯 - 沒有人爲此付出時間;))

相關問題