1

我在显示我的 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”作为相应类的要求

谢谢。

4

1 回答 1

2

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

  • 定义你Ext.data.Storedata配置(在这种情况下是内联数据)

  • 假设您定义的 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'
}
});
于 2012-05-12T10:56:34.737 回答