簡體   English   中英

Sencha Touch使一個簡單的按鈕起作用

[英]Sencha Touch Making a simple button work

我很難調試和理解為什么在sencha項目中最基本的東西出錯了。 我使用的是webstorm,但似乎對拼寫錯誤的代碼沒有多大幫助。 我得到的大多數錯誤尚不清楚,例如undefined不是函數。 任何人都可以通過以下代碼向我展示我的錯誤來幫助我。 我只想要一個執行控制台日志的按鈕。

視圖:

    Ext.define('imp.view.Test', {
        extend: 'Ext.form.Panel',
        alias: "widget.test",
        xtype: 'test',
        controllers: 'imp.controller.Test',
        requires: [ 'imp.controller.Test'],

        config: {
            title:'Test',
            scrollable: null,
            items: [

                {
                    xtype: 'button',
                    itemId: 'postButton',
                    ui: 'action',
                    padding: '10px',
                    text: 'Post'
                }]


        }

});

控制器:

Ext.define('imp.controller.Test', {
    extend: 'Ext.app.Controller',
    config: {
        refs: {
            testView: 'test'
        },
        control: {
            'test #postButton': {
                tap: 'onPostCommand'
            }
        }
    },

        onPostCommand: function (){
            console.log('klik');


        }

    }
);

有什么好的方法可以調試和更好地學習Sencha Touch,有人可以給我一些建議嗎? 什么書,網站等是好的?

更新:這是控制台日志輸出,當我按下按鈕時,什么也沒有發生.....

development.js:21 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
development.js:22 XHR finished loading: GET "http://imp.localhost/imp/bootstrap.json".
development.js:9 GET http://imp.localhost/imp/cordova.js 
sencha-touch.js:13036 The key "minimum-ui" is not recognized and ignored.
Abstract.js?_dc=1427878432368:27 The 'overflowchanged' event is deprecated and may be removed. Please do not use it.
Console.js?_dc=1427878432463:35 [WARN][Anonymous] [Ext.Loader] Synchronously loading 'imp.store.Offline.Opdrachten'; consider adding 'imp.store.Offline.Opdrachten' explicitly as a require of the corresponding class
sencha-touch.js:8381 XHR finished loading: GET "http://imp.localhost/imp/app/store/Offline/Opdrachten.js?_dc=1427878433743".
sencha-touch.js:8381 XHR finished loading: GET "http://imp.localhost/touch/src/data/ArrayStore.js?_dc=1427878433755".
sencha-touch.js:8381 XHR finished loading: GET "http://imp.localhost/touch/src/data/reader/Array.js?_dc=1427878433767".
Console.js?_dc=1427878432463:35 [WARN][Anonymous] [Ext.Loader] Synchronously loading 'imp.store.Offline.Antwoorden'; consider adding 'imp.store.Offline.Antwoorden' explicitly as a require of the corresponding class
sencha-touch.js:8381 XHR finished loading: GET "http://imp.localhost/imp/app/store/Offline/Antwoorden.js?_dc=1427878433786".
Connection.js?_dc=1427878433330:375 GET https://simplemanager.transfer-solutions.com/ords/simplemanager/test1/planningen 401 (Unauthorized)
Connection.js?_dc=1427878433330:375 XHR finished loading: GET "https://simplemanager.transfer-solutions.com/ords/simplemanager/test1/planningen".

找出代碼是否有問題的最佳方法是在Firefox中使用Firebug或在Chrome中使用開發人員工具。

關於您的問題,我只是從代碼中刪除了util.Utility ,它可以正常工作。 因此,您想確定app/util文件夾中是否有Utility.js 另外, Utility.js應該遵循Sencha類結構:

Ext.define('.util.Utility', { /*upper case "U" in important*/
      config : {
      }
});

最后,您應該在控制台輸出中看到klik或錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM