我正在尝试通过启动 blaze helpers 来制作 Flickity Carousel。我确实有以下错误:
Exception in template helper: TypeError: $(...).flickity is not a function
这是我的轮播模板助手:
Template.carouselTemplate.onCreated(function bodyOnCreated() {
this.state = new ReactiveDict();
Meteor.subscribe('albums');
})
Template.carouselTemplate.helpers({
albums() {
return Albums.find({});
},
initializeCarousel () {
$('.carousel').flickity({
// options
"lazyLoad": true
});
}
});
和模板本身:
<template name='carouselTemplate'>
<div class="carousel">
{{#each albums}}
<div class="carousel-cell">
<img src={{cover}} alt="cat nose" />
</div>
{{/each}}
{{initializeCarousel}}
</div>
<template />
PS:我愿意接受其他方式来完成这项工作。