嗨,大家好,我想让AngularJs变得卑鄙,我遵循了他们的文档,但仍然无法正常工作。
这是我的代码片段:
脚本:
(function() {
var bLazy = new Blazy({
breakpoints: [
{
width: 420, // max-width
src: 'data-blazy-small'
},
{
width: 1200, // max-width
src: 'data-blazy-large'
},
]
, success: function(element){
setTimeout(function(){
var parent = element.parentNode;
parent.className = parent.className.replace(/\bloading\b/,'');
}, 200);
}
});
})();
HTML:
<img ng-repeat = "image in main.imageLists"
class="b-lazy"
data-blazy-large="{{image.largeImg}}"
data-blazy-small="{{image.smallImg}}"
alt="Responsive Images" />
控制器:
this.imageLists = [{ smallImg:'assets/images/bear-small1.jpg',
largeImg:'assets/images/big-bear2.jpg',
},
{ smallImg:'assets/images/bear-small2.jpg',
largeImg:'assets/images/big-bear1.jpg',
}];
目的是使用ng-src正确解析,但不会发生延迟加载。您能告诉我我在这里做错了什么吗?
最佳答案
var bLazy = new Blazy({→var blazy = new Blazy({
img标签需要“ src”
参考〜http://dinbror.dk/blog/blazy/#Multi(多服务图像)
关于javascript - Blazy在AngularJS上,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34216120/