class index {
constructor() {
this.mySwiper = null;
this.GetThreeMeals();
footer()
}
async GetThreeMeals() {
var res = await indexServe.threeMeals();
console.log(res);
res.forEach((v, i) => {
$(".test").append(`
${v.title}`);
$(".banner .swiper-wrapper").append(`
${v.content.map((item) => {
return `

`
}).toString().replaceAll(",", "")}
`)
});
var self = this;
$(".test li").click(function () {
$(this).addClass("active").siblings().removeClass("active");
self.mySwiper.slideTo($(this).index())
});
this.initThreeMealsSwiper()
}
initThreeMealsSwiper() {
this.mySwiper = new Swiper('.banner', {
direction: 'horizontal', // 垂直切换选项
// 如果需要分页器
pagination: {
el: '.swiper-pagination',
},
on: {
slideChangeTransitionEnd: function () {
$(".test li").eq(this.activeIndex).addClass("active").siblings().removeClass("active")
},
},
})
}
}
new index()