作者:心若在梦就在_2012 | 来源:互联网 | 2023-08-18 13:59
IwanttocreateaforloopthatwillgenerateanewelementforsampleItemsbasedonafixednumber
I want to create a for loop that will generate a new element for sampleItems
based on a fixed number set in a for loop.
我想创建一个for循环,它将根据for循环中设置的固定数字为sampleItems生成一个新元素。
var list = new WinJS.Binding.List();
var groupedItems = list.createGrouped(
function groupKeySelector(item) { return item.group.key; },
function groupDataSelector(item) { return item.group; }
);
generateSampleData().forEach(function (item) {
list.push(item);
});
function generateSampleData() {
var sampleGroups = [
{ key: "group1", title: "Event1", backgroundImage: "/images/event1.jpg"}
];
var sampleItems = [
{ group: sampleGroups[0], title: "Item Title: 1", content: "http://192.168.201.41/Stream" + [i] + ".mp4", backgroundImage: "/images/image1.jpg" }
];
return sampleItems;
}
I tried to place a for loop within sampleItems
but i'm not allowed place the loop there.
我试图在sampleItems中放置一个for循环,但我不允许在那里放置循环。
2 个解决方案