通用轮播组件文档 - layui.carousel
https://www.layui.com/doc/modules/carousel.html
/**********carousel 轮播 start**********/
//通用轮播组件文档 - layui.carousel https://www.layui.com/doc/modules/carousel.html
//图片轮播
var ins;
var options = {
elem: '#test10'
,width: '100%'
,height: '320px'
,arrow: 'always' //始终显示箭头
,nim: 'updown' //切换动画方式
,autoplay: true
,interval: 3000
}
update_carousel();
function update_carousel(){
layui.use(['carousel', 'form'], function(){
var carousel = layui.carousel
,form = layui.form;
//图片轮播
ins =carousel.render(options);
var $ = layui.$, active = {
set: function(othis){
var THIS = 'layui-bg-normal'
,key = othis.data('key')
,options = {};
othis.css('background-color', '#5FB878').siblings().removeAttr('style');
options[key] = othis.data('value');
ins3.reload(options);
}
};
//监听开关
form.on('switch(autoplay)', function(){
ins3.reload({
autoplay: this.checked
});
});
$('.demoSet').on('keyup', function(){
var value = this.value
,options = {};
if(!/^\d+$/.test(value)) return;
options[this.name] = value;
ins3.reload(options);
});
//其它示例
$('.demoTest .layui-btn').on('click', function(){
var othis = $(this), type = othis.data('type');
active[type] ? active[type].call(this, othis) : '';
});
//重置轮播
//ins.reload(options);
});
}
/*************carousel 轮播 end**********/