您遵循的教程是旧式的,我建议您遵循本教程。
相同的应用程序,但您遵循的不是 MVC,我分享的教程遵循 MVC,我在开始 sencha touch 时遵循了本教程。
这个应用程序对你来说是一个很好的开始,另外我想提一下,这个应用程序只是一个不完美的开始。
随着您了解更多,您将了解最佳实践。
话虽如此,让我们解决旧代码中的警告
您刚刚定义了商店,但没有在商店管理器中创建和注册 NotesStore
Ext.regStore(id,config)会为你做这件事,试试这个代码。
Ext.application({
name : ('SF' || 'SenchaFiddle'),
launch : function() {
Ext.define('Notes', {
extend: 'Ext.data.Model',
id: 'modelId',
config: {
fields: [
{ name: 'id', type: 'int' },
{ name: 'date', type: 'date', dateFormat: 'c' },
{ name: 'title', type: 'string' },
{ name: 'narrative', type: 'string' }
],
validations: [
{ type: 'presence', field: 'id' },
{ type: 'presence', field: 'title' }
]
}
});
Ext.regStore('NotesStore', {
require: 'Ext.data.Store',
model: 'Notes',
storeId : 'NotesStore',
sorters: [{
property: 'date',
direction: 'DESC'
}],
proxy: {
type: 'localstorage',
id: 'notes-app-store'
},
// TODO: remove this data after testing.
data: [
{ id: 1, date: new Date(), title: 'Test Note', narrative: 'This is simply a test note' }
]
});
Ext.Viewport.add({
xtype: 'panel',
fullscreen: true,
layout: 'card',
html: "hello",
items: [{
xtype: 'panel',
id: 'notesListContainer',
layout: 'fit',
html: 'This is the notes list container',
items: [{
xtype: 'toolbar',
docked: 'top',
id: 'notesListToolbar',
title: 'My Notes'
},
{
xtype: 'list',
id: 'notesList',
//require: ['Notes.model.Notes','NotesApp.store.NotesStore'],
store: 'NotesStore',
itemTpl: '<div class="list-item-title">{title}</div>' +
'<div class="list-item-narrative">{narrative}</div>'
}]
}]
});
}
});