要在backbone实现这样的效果
Document
backbone
tpl
{{~it.item_list:v:index}}
{{~}}
views
define(["doT","text!components/modules/slide/tpl.html","components/modules/slide/view","swiper"],function (doT,tpl,Model,swiper) {
var view= Backbone.View.extend({
id: "modules-slide",
template: doT.template(tpl),
events:{},
initialize: function () {},
render: function () {
this.$el.html(this.template(this.model));
this.$el.find(".swiper-container").swiper({
loop: true,
pagination: $(".swiper-pagination", this.$el)[0],
autoplay: 2500,
autoplayDisableOnInteraction:false,
paginationClickable: true,
lazyLoading: true//如果要延迟加载图片就有问题
});
return this
},
});
return view;
})
渲染后是这样的

但是网页内容是空白的,除非我把src换成src 还有把lazyLoading:true删掉
求解决办法
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
引用swiper 3.3.1试试吧
这个主要和backbone的机制有关系 $el前后 的关系
我之前遇到这个问题是因为添加了页面缓存导致懒加载失效。
如果这里的默认懒加载失效可以尝试更换其他的加载方式