admin管理员组文章数量:1430407
I'm trying to display a horizontal timeline on my HTML page. I'm having trouble with my swiper slider, the next and prev buttons do not work at all, I've included the library as well, still doesn't work, I don't understand why. No errors are shown in console, buttons are clickable but do not function at all. How do I fix this? Below is the code
<div id="app" class="container">
<div class="row">
<div class="col-md-12">
<div class="swiper-container">
<p class="swiper-control">
<button type="button" class="btn btn-default btn-sm prev-slide">Prev</button>
<button type="button" class="btn btn-default btn-sm next-slide">Next</button>
</p>
<div class="swiper-wrapper timeline">
<div class="swiper-slide" v-for="item in steps">
<div class="timestamp">
<span class="date">{{item.dateLabel}}<span>
</div>
<div class="status">
<span>{{item.title}}</span>
</div>
</div>
</div>
<!-- Add Pagination -->
<div class="swiper-pagination"></div>
</div>
</div>
</div>
</div>
<script src="/[email protected]"></script>
<script>
const data = [{
dateLabel: 'January 2017',
title: 'Gathering Information'
},
{
dateLabel: 'February 2017',
title: 'Planning'
},
{
dateLabel: 'March 2017',
title: 'Design'
},
{
dateLabel: 'April 2017',
title: 'Content Writing and Assembly'
},
{
dateLabel: 'May 2017',
title: 'Coding'
},
{
dateLabel: 'June 2017',
title: 'Testing, Review & Launch'
},
{
dateLabel: 'July 2017',
title: 'Maintenance'
}
];
new Vue({
el: '#app',
data: {
steps: data,
},
mounted() {
var swiper = new Swiper('.swiper-container', {
slidesPerView: 4,
paginationClickable: true,
grabCursor: true,
paginationClickable: true,
nextButton: '.next-slide',
prevButton: '.prev-slide',
});
}
})
I'm trying to display a horizontal timeline on my HTML page. I'm having trouble with my swiper slider, the next and prev buttons do not work at all, I've included the library as well, still doesn't work, I don't understand why. No errors are shown in console, buttons are clickable but do not function at all. How do I fix this? Below is the code
<div id="app" class="container">
<div class="row">
<div class="col-md-12">
<div class="swiper-container">
<p class="swiper-control">
<button type="button" class="btn btn-default btn-sm prev-slide">Prev</button>
<button type="button" class="btn btn-default btn-sm next-slide">Next</button>
</p>
<div class="swiper-wrapper timeline">
<div class="swiper-slide" v-for="item in steps">
<div class="timestamp">
<span class="date">{{item.dateLabel}}<span>
</div>
<div class="status">
<span>{{item.title}}</span>
</div>
</div>
</div>
<!-- Add Pagination -->
<div class="swiper-pagination"></div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr/npm/[email protected]"></script>
<script>
const data = [{
dateLabel: 'January 2017',
title: 'Gathering Information'
},
{
dateLabel: 'February 2017',
title: 'Planning'
},
{
dateLabel: 'March 2017',
title: 'Design'
},
{
dateLabel: 'April 2017',
title: 'Content Writing and Assembly'
},
{
dateLabel: 'May 2017',
title: 'Coding'
},
{
dateLabel: 'June 2017',
title: 'Testing, Review & Launch'
},
{
dateLabel: 'July 2017',
title: 'Maintenance'
}
];
new Vue({
el: '#app',
data: {
steps: data,
},
mounted() {
var swiper = new Swiper('.swiper-container', {
slidesPerView: 4,
paginationClickable: true,
grabCursor: true,
paginationClickable: true,
nextButton: '.next-slide',
prevButton: '.prev-slide',
});
}
})
Share
Improve this question
edited Oct 6, 2019 at 7:41
apson11
asked Oct 6, 2019 at 6:37
apson11apson11
511 gold badge3 silver badges7 bronze badges
2
- can you share the markup as well? – Nidhin Joseph Commented Oct 6, 2019 at 7:22
- hello, just added my html part. – apson11 Commented Oct 6, 2019 at 7:42
1 Answer
Reset to default 2Rearranged a few scripts. Made some changes to Swiper config. Please see it this helps!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<script src="https://cdn.jsdelivr/npm/[email protected]"></script>
<link rel="stylesheet" href="https://unpkg./swiper/css/swiper.min.css">
</head>
<body>
<div id="app" class="container">
<div class="row">
<div class="col-md-12">
<div class="swiper-container">
<p class="swiper-control">
<button type="button" class="btn btn-default btn-sm prev-slide">Prev</button>
<button type="button" class="btn btn-default btn-sm next-slide">Next</button>
</p>
<div class="swiper-wrapper timeline">
<div class="swiper-slide" v-for="item in steps">
<div class="timestamp">
<span class="date">{{item.dateLabel}}<span>
</div>
<div class="status">
<span>{{item.title}}</span>
</div>
</div>
</div>
<!-- Add Pagination -->
<div class="swiper-pagination"></div>
</div>
</div>
</div>
</div>
<script
src="https://cdnjs.cloudflare./ajax/libs/Swiper/4.5.1/js/swiper.min.js"
integrity="sha256-4sETKhh3aSyi6NRiA+qunPaTawqSMDQca/xLWu27Hg4="
crossorigin="anonymous"
></script>
<script>
const data = [
{
dateLabel: "January 2017",
title: "Gathering Information"
},
{
dateLabel: "February 2017",
title: "Planning"
},
{
dateLabel: "March 2017",
title: "Design"
},
{
dateLabel: "April 2017",
title: "Content Writing and Assembly"
},
{
dateLabel: "May 2017",
title: "Coding"
},
{
dateLabel: "June 2017",
title: "Testing, Review & Launch"
},
{
dateLabel: "July 2017",
title: "Maintenance"
}
];
new Vue({
el: "#app",
data: {
steps: data
},
mounted() {
var swiper = new Swiper(".swiper-container", {
slidesPerView: 3,
spaceBetween: 30,
pagination: {
el: ".swiper-pagination",
clickable: true
},
navigation: {
nextEl: ".next-slide",
prevEl: ".prev-slide"
}
});
}
});
</script>
</body>
</html>
本文标签: javascriptSwiperNext and prev buttons do not workStack Overflow
版权声明:本文标题:javascript - Swiper - Next and prev buttons do not work - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745521468a2661644.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论