我正在使用MVVM 架构开发Extjs 6应用程序。我在文件夹中有一个模型如下: MyApp/model
Ext.define('MyApp.model.User', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'},
{name: 'age', type: 'int'}
]
});
我在MyApp/store文件夹中的存储如下:
Ext.define('MyApp.store.User', {
extend: 'Ext.data.Store',
model: 'MyApp.model.User',
data : [
{firstName: 'Seth', age: 34},
{firstName: 'Scott', age: 72},
{firstName: 'Gary', age: 19},
{firstName: 'Capybara', age: 208}
]
});
并且Application.js在/MyApp文件夹中添加商店如下:
stores: [
'User'
]
现在我在我的应用程序中存储如下:
app = MyApp.getApplication();
users = app.getStore('User');
如何获取商店的数据?users.getData()? 当我使用users.getData()它时,它会返回[undefined x 4]。问题出在哪里?它工作正常吗?