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 class 结构:

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

最后,您应该会在控制台输出中看到 klik 或错误。