Sencha Touch 轮播随机化
我目前有一个静态轮播设置如下:
varPanelTop = new Ext.Carousel({
defaults: {
cls: 'homeTop'
},
items: [{
html: '<img src="IMAGE ONE" />'
},
{
html: '<img src="IMAGE TWO" />'
},
{
html: '<img src="IMAGE THREE" />'
},
{
html: '<img src="IMAGE FOUR" />'
}]
});
不是问题,一切正常,但现在我遇到了一个大问题,其中“我可以这样做,以便每次刷新此页面时 html/imgs 的顺序每次都不同?
那么这是否可能做到,如果可以的话怎么做?
非常感谢
I currently have a static carousel set up as below:
varPanelTop = new Ext.Carousel({
defaults: {
cls: 'homeTop'
},
items: [{
html: '<img src="IMAGE ONE" />'
},
{
html: '<img src="IMAGE TWO" />'
},
{
html: '<img src="IMAGE THREE" />'
},
{
html: '<img src="IMAGE FOUR" />'
}]
});
Not a problem all works fine, but now i have been thrown a big one, in which 'can i do this so that each time this page is refreshed the order of the html/imgs are different each time?
So would this be possible to do and how if so?
Many Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是有可能的。有一个包含这样的对象的数组:
然后根据您显示轮播的时间,您将拥有:
等。您可以检查图像是否已添加,即您需要的只是一个随机数列表,然后将图像添加到轮播中,就像这样。然后您调用
以显示图像。
请注意,carouselId 是轮播对象的“id”属性,但是有更好的方法来获取轮播对象。这完全取决于你在哪里拥有它。
It's possible. Have an array with objects like this:
Then depending when you show the carousel you will have:
etc. you can check if the images were added already i.e. all you need is a list of random numbers and you add the images to the carousel like that. Afterwards you call
to display the images.
Note that carouselId is the "id" property of the carousel object, but there are better ways to get to the carousel object. It all depends where you have it.