$('#fullpage').fullpage({
anchors: ['page1', 'page2', 'page3', 'page4', 'page5', 'page6'],
sectionsColor: ['yellow', 'orange', '#C0C0C0', '#ADD8E6', 'blue', 'green'],
onLeave: function(index, nextIndex, direction) {
$('#ind').text("nextIndex = " + nextIndex);
if (nextIndex > 4 && direction === 'down') {
$.fn.fullpage.moveTo('page1');
return false;
}
}
});
//adding the action to the button
$(document).on('click', '#moveTo', function() {
$.fn.fullpage.moveTo(2, 1);
});
.section {
text-align: center;
font-size: 3em;
}
/**
Fixed button outside the fullpage.js wrapper
*/
#moveTo {
top: 20px;
left: 20px;
position: fixed;
z-index: 999;
background: #09f;
font-size: 1em;
cursor: pointer;
}
#ind {
top: 40px;
left: 20px;
position: fixed;
z-index: 999;
font-size: 1em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://rawgit.com/alvarotrigo/fullPage.js/master/jquery.fullPage.js"></script>
<div id="moveTo">Move to page2 slide 2</div>
<div id="ind"></div>
<div id="fullpage">
<div class="section">One</div>
<div class="section">
<div class="slide" data-anchor="slide1">Two 1</div>
<div class="slide" data-anchor="slide2">Two 2</div>
</div>
<div class="section">Three</div>
<div class="section">Four</div>
<div class="section">Five</div>
<div class="section">Six</div>
</div>
不,不會解決問題。看到建議的答案[這裏](https://github.com/alvarotrigo/fullPage.js/issues/2052#issuecomment-223256222)。 – Alvaro