Sencha Touch制作简单的按钮

时间:2015-03-27 14:43:25

标签: javascript extjs touch

我很难调试和理解为什么在我的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".

1 个答案:

答案 0 :(得分:1)

了解代码是否有问题的最佳方法是在Firefox中使用Firebug或在Chrome中使用开发者工具。

参考您的问题,我刚从代码中删除了util.Utility,它运行正常。因此,您需要确保Utility.js文件夹中是否有app/util。此外,Utility.js应遵循Sencha类结构:

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

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