只需創建它的一個實例爲任何其它視圖或組件。
要麼做這個...
items: [
Ext.create('myApp.view.TripList')
]
或者用它的別名(的xtype)...
items:[
{
xtype: 'TripListView',
....
}
]
編輯
這裏有一個小提琴:https://fiddle.sencha.com/#fiddle/3hg
這裏是代碼...
Ext.define('MyApp.model.Trip', {
extend: 'Ext.data.Model',
config: {
fields: [{
name: 'Name',
type: 'auto'
}, {
name: 'Date',
type: 'auto'
}, {
name: 'Friends',
type: 'auto'
}, {
name: 'Description',
type: 'auto'
}
]
}
});
Ext.define('MyApp.store.Trips', {
extend: 'Ext.data.Store',
defaultRootProperty: 'Name',
requires: ['MyApp.model.Trip'],
config: {
model: 'MyApp.model.Trip',
storeId: 'TripStore',
autoLoad: true,
data: [{
Name: 'Thailand Trip',
Date: '2014.03.03',
Friends: '[email protected], [email protected]',
Description: 'We will explore the hustle and bustle markets in the acient country.'
}, {
Name: 'Malysia Trip',
Date: '2014.03.03',
Friends: '[email protected], [email protected]',
Description: 'We will explore the hustle and bustle markets in the acient country.'
}, {
Name: 'U.S.A. Trip',
Date: '2014.03.03',
Friends: '[email protected], [email protected]',
Description: 'We will explore the hustle and bustle markets in the acient country.'
}, {
Name: 'The Great China Trip',
Date: '2014.03.03',
Friends: '[email protected], [email protected]',
Description: 'We will explore the hustle and bustle markets in the acient country.'
}]
}
});
Ext.define('MyApp.view.TripList', {
requires: ['MyApp.store.Trips'],
extend: 'Ext.List',
xtype: 'TripListView',
config:{
itemTpl: '{Name}',
fullscreen:true,
store: Ext.create('MyApp.store.Trips').load()
}
});
Ext.define('MyApp.view.Main', {
extend: 'Ext.tab.Panel',
xtype: 'main',
requires: ['Ext.TitleBar', 'Ext.Video', 'Ext.dataview.List', 'Ext.XTemplate', 'MyAccountant.view.TripList'],
config: {
tabBarPosition: 'bottom',
items: [{
title: 'Trip List',
iconCls: 'list',
layout:'fit',
items: [
Ext.create('MyApp.view.TripList',{
width:'100%'
})
]
}, {
title: 'Welcome',
iconCls: 'home',
styleHtmlContent: true,
scrollable: true,
items: {
docked: 'top',
xtype: 'titlebar',
title: 'Welcome to Sencha Touch 2'
},
html: ["You've just generated a new Sencha Touch 2 project. What you're looking at right now is the ", "contents of <a target='_blank' href=\"app/view/Main.js\">app/view/Main.js</a> - edit that file ", "and refresh to change what's rendered here."].join("")
}]
}
});
/*
This file is generated and updated by Sencha Cmd. You can edit this file as
needed for your application, but these edits will have to be merged by
Sencha Cmd when it performs code generation tasks such as generating new
models, controllers or views and when running "sencha app upgrade".
Ideally changes to this file would be limited and most work would be done
in other places (such as Controllers). If Sencha Cmd cannot merge your
changes and its generated code, it will produce a "merge conflict" that you
will need to resolve manually.
*/
Ext.application({
name: 'MyApp',
controolers: ['MyApp.controller.Main'],
views: ['Main', 'MyApp.view.TripList'],
launch: function() {
// Destroy the #appLoadingIndicator element
// Initialize the main view
Ext.Viewport.add(Ext.create('MyApp.view.Main'));
},
onUpdated: function() {
Ext.Msg.confirm("Application Update", "This application has just successfully been updated to the latest version. Reload now?",
function(buttonId) {
if (buttonId === 'yes') {
window.location.reload();
}
});
}
});
hi lascort,thx to your reply。然而,我得到一個錯誤:未捕獲的錯誤:[錯誤] [Ext.Container#doAdd]添加卡片到標籤容器中,而沒有指定任何標籤配置。在按照你的方式之後。 – Franva
在我的編輯回答,順便說一句,你應該在你的文章中提到的錯誤,可能它的標題,標題有點誤導 – lascort
嗨,我沒有在我的原代碼中的錯誤,因爲我有標題, iconCls等在我原來的代碼。 – Franva