A Pen by Terry Zeng on CodePen.
Created
May 20, 2018 09:29
-
-
Save TerryZ/4ad7878c02948129d18e9187d3b74fd7 to your computer and use it in GitHub Desktop.
v-page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="app"> | |
<div class="photo-wall"> | |
<div v-for="num in pageArr" v-html="num" class="brick"></div> | |
</div> | |
<v-page :setting="pagePhoto" @page-change="pagePhotoChange"></v-page> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vue.use(vPage.default); | |
new Vue({ | |
el: "#app", | |
data() { | |
let arr = []; | |
for (let i = 0; i < 108; i++) { | |
arr.push(i + 1); | |
} | |
return { | |
pagePhoto: { | |
totalRow: arr.length, | |
language: "en", | |
align: "center" | |
}, | |
arr: arr, | |
pageArr: [] | |
}; | |
}, | |
methods: { | |
pagePhotoChange(pInfo) { | |
this.pageArr.splice(0, this.pageArr.length); | |
let start = 0, | |
end = 0; | |
start = pInfo.pageSize * (pInfo.pageNumber - 1); | |
end = start + pInfo.pageSize; | |
if (end > this.arr.length) end = this.arr.length; | |
for (let i = start; i < end; i++) { | |
this.pageArr.push(this.arr[i]); | |
} | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.min.js"></script> | |
<script src="https://unpkg.com/v-page@1.4.0/dist/v-page.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
div.photo-wall{ | |
display: block; | |
width: 970px; | |
margin: 0 auto; | |
} | |
div.photo-wall div.brick { | |
border: 1px solid #ddd; | |
border-radius: 2px; | |
background-color: #f4f4f4; | |
text-align: center; | |
line-height: 100%; | |
float: left; | |
margin: 0 10px 10px 0; | |
width: 180px; | |
height: 100px; | |
font-size: 60px; | |
color: #bbb; | |
padding-top: 35px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment