GET http://localhost/H5/Hiruscar/Mon%20Mar%2005%202018%2020:09:30%20GMT+0800%20(%E4%B8%AD%E5%9B%BD%E6%A0%87%E5%87%86%E6%97%B6%E9%97%B4)&i=89 404 (Not Found)
一直出现以上的报错
这是我的写法,是不是baseUrl写错了?
var baseUrl = 'http://localhost/H5/Hiruscar' + new Date,
$log = $('.swiper-container').val(''),
$progress = $('.swiper-container').text('0 / 100'),
loader = new PxLoader();
// add 100 images to the queue
for(var i=0; i < 100; i++) {
// this time we'll create a PxLoaderImage instance instead of just
// giving the loader the image url
var pxImage = new PxLoaderImage(baseUrl + '&i=' + i);
// we can add our own properties for later use
pxImage.imageNumber = i + 1;
loader.add(pxImage);
}
// callback that runs every time an image loads
loader.addProgressListener(function(e) {
// log which image completed
$log.val($log.val() + 'Image ' + e.resource.imageNumber + ' Loaded\r');
// scroll to the bottom of the log
$log.scrollTop($log[0].scrollHeight);
// the event provides stats on the number of completed items
$progress.text(e.completedCount + ' / ' + e.totalCount);
});
loader.start();
少了问好了吧,要变为参数,要不就是路径了
var baseUrl = 'http://localhost/H5/Hiruscar?' + new Date,
虽然已采纳,还是不对的,以下是正确写法:
//需要加载的图片名称
var baseUrl = ['first_page_bg_1.jpg'];
//实例化
loader = new PxLoader();
//根据图片名称遍历
for(var i=0; i < baseUrl.length; i++) {
loader.addImage('/H5/Hiruscar-h-6/html/images/' + baseUrl[i] );
}
//加载成功后执行
loader.addCompletionListener(function() {
//这里放成功后该执行的代码
}
loader.start();