gpt4 book ai didi

addition - 将元素添加到轮播 sencha

转载 作者:行者123 更新时间:2023-12-02 08:54:11 28 4
gpt4 key购买 nike

sencha touch中,我有一个如下声明的轮播:

ajaxNav = new Ext.Panel({    
scroll: 'vertical',
cls: 'card1 demo-data',
styleHtmlContent: true,
layout: {
type: 'vbox',
align: 'stretch'
},
defaults: {
flex: 1
},
items: [{
xtype: 'carousel',
items: [{
id:'tab-1',
html: '',
cls: 'card card1'
},
{
id:'tab-2',
html: '<p>Clicking on either side of the indicators below</p>',
cls: 'card card2'
},
{
id:'tab-3',
html: 'Card #3',
cls: 'card card3'
}]
}]
});

有人知道如何动态添加元素吗?

最佳答案

我给您写了一个简单的示例,向您展示如何动态地将新面板添加到现有的 Ext.Carousel 元素。

Ext.setup({

onReady: function() {

var ajaxNav = new Ext.Carousel({
fullscreen: true,
dockedItems: {
xtype: 'toolbar',
title: 'Demo',
items: [{
xtype: 'button',
ui: 'action',
text: 'Add',
handler: function(){

var element = new Ext.Panel({
html: 'New Element'
});

ajaxNav.add(element);
ajaxNav.doLayout();

}
}]
},
items: [{
id:'tab-1',
html: '',
cls: 'card card1'
},{
id:'tab-2',
html: '<p>Clicking on either side of the indicators below</p>',
cls: 'card card2'
},{
id:'tab-3',
html: 'Card #3',
cls: 'card card3'
}]
});

}

});

正如您所看到的,在“添加”按钮事件上,您首先必须根据您的需要定义面板,然后将其添加到您的轮播中,最重要的是,您必须让轮播重新计算他的布局调用“doLayout()”函数。

希望这有帮助。

关于addition - 将元素添加到轮播 sencha,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6189482/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com