TypeError:Swiper不是构造函数

时间:2017-03-17 01:13:26

标签: meteor meteor-blaze swiper

我试图让Swiper工作,但它总是给我一个错误“Swiper不是构造函数”

我使用http://idangero.us/swiper/get-started/#.WMsuihJ96MI作为Swiper库并将此库安装为流星包。

的客户机/ body.js

Template.slider.onRendered(function(){
     var mySwiper = new Swiper ('.swiper-container', {

     // Optional parameters
     direction: 'vertical',
     loop: true,

     // If we need pagination
     pagination: '.swiper-pagination',

     // Navigation arrows
     nextButton: '.swiper-button-next',
     prevButton: '.swiper-button-prev',

     // And if we need scrollbar
     scrollbar: '.swiper-scrollbar',
  });
});

的客户机/ body.html

<body>
   <h1>Test</h1>
 {{> slider }}
</body>

 <template name="slider">
   <!-- Slider main container -->
 <div class="swiper-container">
     <!-- Additional required wrapper -->
     <div class="swiper-wrapper">
         <!-- Slides -->
         <div class="swiper-slide">Slide 1</div>
         <div class="swiper-slide">Slide 2</div>
         <div class="swiper-slide">Slide 3</div>
     </div>
     <!-- If we need pagination -->
     <div class="swiper-pagination"></div>

     <!-- If we need navigation buttons -->
     <div class="swiper-button-prev"></div>
     <div class="swiper-button-next"></div>

     <!-- If we need scrollbar -->
     <div class="swiper-scrollbar"></div>
 </div>
</template>

2 个答案:

答案 0 :(得分:3)

@mutdmour您应该尝试Swiper.default(element,options)

确保控制你Swiper实例并检查它是否真的是一个构造函数,或者它是一个在其属性中具有它的构造函数的对象。对不起,如果我提供了错误的信息。因为我的英语很弱,这是我对论坛的第一次回复。

答案 1 :(得分:0)

就我而言,我通过更改来解决它 import {Swiper, SwiperOptions} from "swiper";import Swiper, {SwiperOptions} from "swiper";