NivoSlider错误

时间:2014-08-19 11:31:03

标签: javascript nivo-slider

我使用NivoSlider并且我想在加载后停止它(手动启动它)。

我使用以下代码:

<script type="text/javascript">
    $(window).load(function() {
        $('#slider1').nivoSlider({
            effect: 'random', // Specify sets like: 'fold,fade,sliceDown'
            slices: 15, // For slice animations
            boxCols: 8, // For box animations
            boxRows: 4, // For box animations
            animSpeed: 800, // Slide transition speed
            pauseTime: 3000, // How long each slide will show
            startSlide: 0, // Set starting Slide (0 index)
            directionNav: false, // Next & Prev navigation
            controlNav: false, // 1,2,3... navigation
            controlNavThumbs: false, // Use thumbnails for Control Nav
            pauseOnHover: false, // Stop animation while hovering
            manualAdvance: false, // Force manual transitions
            paused:true,
            afterLoad: function(){
            $('#slider1').data('nivoSlider').stop();
 }
        });
    });

</script>

但我得到了 Error: Uncaught TypeError: Cannot read property 'stop' of undefined.

1 个答案:

答案 0 :(得分:1)

afterLoad()这个背景下,它是NivoSlider。因此,您只需拨打this.stop()

afterLoad: function() {
    this.stop();
}