JavaScript + Swiper 开发遇到的问题 -- 数据动态加载后无法轮播

window.onload = function () {
        slideshow0();
    }
    function slideshow0() { //轮播图
        new Swiper('#slideshow0', {
            centeredSlides: true, //居中
            direction: 'horizontal', // shuipin切换选项
            loop: true, // 循环模式选项
            speed: 3000,
            // 如果需要分页器
            pagination: {
                el: '.swiper-pagination',
            },
            //observeSlideChildren: true, //子slide更新时,swiper是否更新
            //observer: true,
            slidesPerView: 1, //1.5
            //observer: true, //当改变swiper的样式(例如隐藏/显示)或者修改swiper的子元素时,自动初始化swiper
            // 如果需要前进后退按钮
            // navigation: {
            // 	nextEl: '.swiper-button-next',
            // 	prevEl: '.swiper-button-prev',
            // },
            autoplay: {
                disableOnInteraction: false, //手动滑动之后不打断播放
                delay: 3000
            },
            preloadImages: false,

            // coverflowEffect: {
            // 	rotate: 0,
            // 	stretch: -150,
            // 	depth: 500,
            // 	modifier: 1,
            // 	slideShadows: false,
            // } ,
            // effect : 'coverflow',

        });
        
    }
发布了35 篇原创文章 · 获赞 0 · 访问量 1650

猜你喜欢

转载自blog.csdn.net/weixin_43047070/article/details/102676688
今日推荐