图片加载中的异步操作,如何确保顺序
if( productImgs.length > 0 )
{
for(var i = 0;i < productImgs.length;i++)
{
var img = new Image();
img.onload = function()
{
$slides.append('
console.log(productImgs.length+''+this.i);
if(this.i == productImgs.length-1)
{
i = null;
//图片滑动部分实例化
$slides.slidesjs({
width: $slides.find("img").width(),
height: $slides.find("img").height(),
navigation: false
});
$('.slidesjs-pagination-item').each(function(i, e) {
$(e).find('a').html(''+(i+1)+''+ '/'+ productLength);
});
console.log(132);
}
}
img.src = productImgs[i].thumb;
img.title = productImgs[i].title
img.i =i;
}
}
此问题的最终目的是让所有图片都加载完成后进行图片滑动部分实例化,然后目前并不能实现,不知道,这种涉及到图片加载顺序的异步操作该如何实现呢?
相关阅读:
使用instruments的Core Animation 测试
React-native 点击子组件tab项 向父组件传status值?
关于页面内 script标签的加载问题
ssh struts2 拦截器死活不起作用
什么是尾递归?
例如HBuilder中,选中一个变量,在当前文档中马上在代码右侧会有相应重复出现的小圆点提示,phpstrom如何能做到这样?
IE6 position:fixed bug (固定窗口方法)
failed to send the handshake ack
Android studio selector 没起作用?
关于CSS3 动画transition的一个问题
正则如何递归匹配大括号?
Release:library not found for -lPods-AFNetworking
关于地图的api统计mysql数据问题
更新jre后数据库处于脱机状态
php CI框架的core/common.php中一些函数的疑问?
在iOS项目中使用 module 和不使用 module 的区别
Model层关系问题:AccessToken与User应该是什么关系?
benchmark是什么东西?
jQuery怎么解绑事件?
如何限制 C# 程序只能访问网络,而不能访问本地文件和其他进程