我在 html 中有这段代码:
echo '<div class="sponsors__item-bg-img lazy-load" data-original="'.$sponsor_item['image'].'" style="background-image: url();" src="https://static.questex.asia/template7/images/grey.gif" ></div></a>';
jquery.lazyload.js 得到了这部分:
$self.one("appear", function() {
if (!this.loaded) {
if (settings.appear) {
var elements_left = elements.length;
settings.appear.call(self, elements_left, settings);
}
$("<img />")
.bind("load", function() {
var original = $self.attr("data-" + settings.data_attribute);
$self.hide();
if ($self.is("img")) {
$self.attr("src", original);
} else {
$self.css("background-image", "url('" + original + "')");
}
$self[settings.effect](settings.effect_speed);
self.loaded = true;
/* Remove image from array so it is not looped next time. */
var temp = $.grep(elements, function(element) {
return !element.loaded;
});
elements = $(temp);
if (settings.load) {
var elements_left = elements.length;
settings.load.call(self, elements_left, settings);
}
})
.attr("src", $self.attr("data-" + settings.data_attribute));
}
});
但是最终的结果是图片没有加载,因为url不是js添加的:
<div class="sponsors__item-bg-img lazy-load" data-original="https://img.questex.asia/sites/default/files/styles/219x164/public/BizProLogo.jpg?itok=KLf9ojX0&timestamp=1527822985" style="background-image: url();" src="https://static.questex.asia/template7/images/grey.gif"></div>
任何人都知道我如何检查发生了什么或我应该如何解决问题?谢谢。