您好,登錄后才能下訂單哦!
這篇文章主要講解了“vue+vue-fullpage怎么實(shí)現(xiàn)整屏滾動(dòng)頁面”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“vue+vue-fullpage怎么實(shí)現(xiàn)整屏滾動(dòng)頁面”吧!
// An highlighted block import router from './router' Vue.config.productionTip = false // 整屏滾動(dòng) import 'fullpage.js/vendors/scrolloverflow'; import VueFullPage from 'vue-fullpage.js'; Vue.use(VueFullPage) /* eslint-disable no-new */ new Vue({ el: '#app', router, components: { App }, template: '<App/>' })
1.html,
<template> <div> <full-page :options="options" id="fullpage" ref="fullpage"> <div > <h4>vue-fullpage.js</h4> </div> <div > <div > <h4>Slide 2.1</h4> </div> <div > <h4>Slide 2.2</h4> </div> <div > <h4>Slide 2.3</h4> </div> </div> <div > <h4>Section 3</h4> </div> </full-page> </div> </template>
2.js
export default { data() { return { options: { anchors: ["page1", "page2", "page3", "page4", "page5", "page6"], licenseKey: "OPEN-SOURCE-GPLV3-LICENSE", afterLoad: this.afterLoad, // method中的方法 即回調(diào)函數(shù) scrollOverflow: true, scrollBar: false, menu: "#menu", sectionsColor: [ "#23A84A", "#ff5f45", "#0798ec", "#fec401", "#000000", "#E7EFFE", ], }, }; }, }
1.afterLoad:對(duì)應(yīng)的函數(shù)寫在methods中,常用作對(duì)頁面的處理
methods:{ afterLoad: function (origin, destination, direction) { // origin 起點(diǎn) destination終點(diǎn) direction方向 固定寫法 this.navIndex = destination.index; //destination.index代表對(duì)應(yīng)頁面index(從0開始) //拿到對(duì)應(yīng)頁面的index就可以進(jìn)行操作 if (destination.index > 0) { this.phoneShow = true; } if (destination.index === 0) { this.phoneShow = false; } }, }
2.moveTo通過事件跳轉(zhuǎn)到對(duì)應(yīng)的page頁面
options: { afterLoad: this.afterLoad, //一定要在options中插入這段數(shù)組,數(shù)組的值對(duì)應(yīng)page頁面 anchors: ["page1", "page2", "page3", "page4", "page5", "page6"], licenseKey: "OPEN-SOURCE-GPLV3-LICENSE", afterLoad: this.afterLoad, // method中的方法 即回調(diào)函數(shù) scrollOverflow: true, scrollBar: false, menu: "#menu", sectionsColor: [ "#23A84A", "#ff5f45", "#0798ec", "#fec401", "#000000", "#E7EFFE", ], }, moveTo(pages) { //固定寫法,第一個(gè)參數(shù)代表options中anchors數(shù)組中的值 //在點(diǎn)擊時(shí)傳遞對(duì)應(yīng)的pages值即可 fullpage_api.moveTo(pages, 1); },
感謝各位的閱讀,以上就是“vue+vue-fullpage怎么實(shí)現(xiàn)整屏滾動(dòng)頁面”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)vue+vue-fullpage怎么實(shí)現(xiàn)整屏滾動(dòng)頁面這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。