【问题标题】:sencha touch 2 issue with Ext.Listsencha touch 2 问题与 Ext.List
【发布时间】:2012-05-12 21:07:21
【问题描述】:

我在显示我的 Ext.list 组件时遇到问题。 这是我的代码:

Ext.define("iphone.view.customers.List", {

extend: 'Ext.List',
xtype: 'customersList',

config: {

    fullscreen: true,
    title: 'Customers List',
    ui: 'round',
    itemTpl: [ '{title}' ],

    data: [
        { title: 'Item 1' },
        { title: 'Item 2' },
        { title: 'Item 3' },
        { title: 'Item 4' }
    ]
}
});

当我启动应用程序时,控制台会产生此警告,但什么也没有出现:

[WARN][Anonymous] [Ext.Loader] 同步加载'Ext.data.Store'; 考虑明确添加“Ext.data.Store”作为 对应类

谢谢。

【问题讨论】:

    标签: listview sencha-touch sencha-touch-2


    【解决方案1】:

    您会看到该警告,因为在 Sencha Touch 2 中执行此操作的最佳做​​法是:

    • 使用data 配置定义您的Ext.data.Store(在这种情况下为内联数据)

    • 假设您定义的 Store 是 listStore,然后在您的列表定义中使用此配置:store: listStore

    希望这会有所帮助。

    你的情况的一个例子:

    Ext.define('iphone.store.Customers', {
        extend: 'Ext.data.Store',
    
        config: {
            model: 'iphone.model.Customer',
                data: [
                          { title: 'Item 1' },
                          { title: 'Item 2' },
                          { title: 'Item 3' },
                          { title: 'Item 4' }
                        ]
        }
    });
    

    并列出:

    Ext.define("iphone.view.customers.List", {
    
    extend: 'Ext.List',
    xtype: 'customersList',
    
    config: {
    
        fullscreen: true,
        title: 'Customers List',
        ui: 'round',
        itemTpl: [ '{title}' ],
    
        store: 'Customers'
    }
    });
    

    【讨论】:

    • 感谢您的回复,但我已经在数据配置中添加了内联数据,正如您在我的代码中看到的那样,列表也没有出现。
    • 我已经更新了一些代码,通常你应该这样做,如果有错误,它们是可能与布局配置相关的次要错误。如果您仍然遇到错误,请告诉我
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-19
    • 1970-01-01
    • 1970-01-01
    • 2013-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多