作者:欢喜星空物语 | 来源:互联网 | 2023-05-17 09:12
I'm using a api to get images it needs to be so that it first loads 10 images and when I click the button it has to add 10 images so I did this:
我正在使用api来获取它需要的图像,以便它首先加载10个图像,当我单击按钮时,它必须添加10个图像,所以我这样做:
The observable amount for the images
图像的可观察量
public imageAmount:KnockoutObservable = ko.observable(10);
Here I slice the array based on the imageAmount. This works fine.
在这里,我基于imageAmount对数组进行切片。这很好用。
var images = response.data.slice(0, this.imageAmount()).map((data=IImageData) =>
{
return {
big: 'http://d1ftcqzt8gr3o4.cloudfront.net/'+ data.big,
thumb: 'http://d1ftcqzt8gr3o4.cloudfront.net/'+ data.thumb
}
});
Then here i update the observable imageamount + 10 on click of the button.
然后在这里我点击按钮更新可观察的imageamount + 10。
public moreImages():void
{
this.viewModel.imageAmount(this.viewModel.imageAmount() + 10);
}
now it is counting up but its not adding the images how can i do this?
现在它正在计数,但它没有添加图像我该怎么办?
HTML
HTML on pastebin could'nt get right format on here
pastebin上的HTML无法在此处获得正确的格式
1 个解决方案