Sencha Touch使一个简单的按钮工作

Sencha Touch Making a simple button work

本文关键字:简单 一个 按钮 工作 Touch Sencha      更新时间:2023-09-26

我很难调试和理解为什么我的sencha项目中最基本的东西会出错。我使用网络风暴,但它似乎对我拼写错误的代码没有多大帮助。我得到的大多数错误都是不清楚的,比如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或错误。