gpt4 book ai didi

meteor - 类型错误 : Swiper is not a constructor

转载 作者:行者123 更新时间:2023-12-03 00:26:20 28 4
gpt4 key购买 nike

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

我正在使用http://idangero.us/swiper/get-started/#.WMsuihJ96MI作为 Swiper 库,并将该库作为 Meteor 包安装。

客户端/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>

最佳答案

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

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

关于meteor - 类型错误 : Swiper is not a constructor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42847518/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com