Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
chevron_left
{{pages[0]}}
...
{{pageNumber}}
...
{{pages[pages.length - 1]}}
chevron_right
css
@import url("https://fonts.googleapis.com/icon?family=Material+Icons"); @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@500;600&display=swap"); :root { --primary: #6b5bfd; --greyLight: #cdd5f7; --greyLight-2: #f8f9ff; --greyDark: #646b8a; } *, *::before, *::after { margin: 0; padding: 0; box-sizing: inherit; } html { box-sizing: border-box; font-size: 62.5%; overflow-y: scroll; font-family: "Poppins", sans-serif; letter-spacing: 0.6px; line-height: 1.4; -webkit-user-select: none; backface-visibility: hidden; -webkit-font-smoothing: subpixel-antialiased; } .container { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; background: var(--greyLight-2); color: var(--greyDark); } ul { list-style-type: none; } .items-list { max-width: 90vw; margin: 2rem; display: grid; grid-template-columns: repeat(5, 1fr); grid-gap: 3rem; justify-content: center; align-content: center; } @media only screen and (max-width: 600px) { .items-list { grid-template-columns: repeat(2, 1fr); } } .item { width: 10rem; height: 10rem; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--greyDark); cursor: pointer; } .item span { background: #ffffff; box-shadow: 0 0.8rem 2rem rgba(90, 97, 129, 0.05); border-radius: 0.6rem; padding: 2rem; font-size: 3rem; transition: all 0.3s ease; } .item:hover span { transform: scale(1.2); color: var(--primary); } .item p { font-size: 1.2rem; margin-top: 1rem; color: var(--greyLight); } .page { display: flex; justify-content: center; align-items: center; height: 5rem; margin: 3rem; border-radius: 0.6rem; background: #ffffff; box-shadow: 0 0.8rem 2rem rgba(90, 97, 129, 0.05); } .page__numbers, .page__btn, .page__dots { display: flex; justify-content: center; align-items: center; margin: 0.8rem; font-size: 1.4rem; cursor: pointer; } .page__dots { width: 2.6rem; height: 2.6rem; color: var(--greyLight); cursor: initial; } .page__numbers { width: 2.6rem; height: 2.6rem; border-radius: 0.4rem; } .page__numbers:hover { color: var(--primary); } .page__numbers.active { color: #ffffff; background: var(--primary); font-weight: 600; border: 1px solid var(--primary); } .page__btn { color: var(--greyLight); pointer-events: none; } .page__btn.active { color: var(--greyDark); pointer-events: initial; } .page__btn.active:hover { color: var(--primary); }
JavaScript
new Vue({ el: "#app", data() { return { items: [], currentPage: 1, perPage: 10, pages: [], icon: [ "invert_colors", "label", "lock", "lock_open", "extension", "favorite", "home", "info", "language", "pets", "print", "receipt", "schedule", "search", "shopping_cart", "star_rate", "support", "thumb_up", "turned_in", "visibility", "work", "warning", "album", "loop", "mic", "videocam", "call", "business", "chat", "email", "location_on", "rss_feed", "vpn_key", "block", "content_copy", "content_cut", "link", "send", "save", "weekend", "access_alarm", "battery_full", "bluetooth", "devices", "sd_storage", "usb", "storage", "attach_money", "highlight", "insert_chart", "publish", "cloud", "attachment", "folder", "computer", "headset", "keyboard_arrow_down", "keyboard_arrow_left", "keyboard_arrow_up", "keyboard_arrow_right", "mouse", "audiotrack", "bedtime", "brush", "camera_alt", "color_lens", "colorize", "edit", "flash_on", "photo", "directions_bus", "flight", "fastfood", "layers", "local_cafe", "local_offer", "local_parking", "map", "restaurant", "apps", "check", "close", "more", "ac_unit", "spa", "smoking_rooms", "architecture", "cake", "luggage", "mood", "person", "school", "share", "sports_esports", "build", "code", "delete", "eco", "explore", "exit_to_app" ] }; }, methods: { // get the 100 items list getItems() { for (i = 0; i < 100; i++) { let template = `
${this.icon[i]}
${i + 1}
`; this.items.push(template); } }, // separate items per page. // Ex: Page 2 -> from item 11 to 20 pagination(items) { let currentPage = this.currentPage; let perPage = this.perPage; let start = currentPage * perPage - perPage; let end = currentPage * perPage; return items.slice(start, end); }, // generate number of pages setPages() { // N of items (100) / 10 items per page let numberOfPages = Math.ceil(this.items.length / this.perPage); //generate 10 pages (100 / 10) for (i = 1; i <= numberOfPages; i++) { this.pages.push(i); } } }, computed: { // display the items per page displayedItems() { return this.pagination(this.items); }, displayedPages() { // if currentPage is page 1 if (this.currentPage === 1) { return this.pages.slice(this.currentPage - 1, this.currentPage + 4); } // if currentPage is the last page else if (this.currentPage === this.pages.length) { return this.pages.slice(this.currentPage - 5, this.currentPage + 1); } // if currentPage is between 4-7 else if (this.currentPage >= 4 && this.currentPage <= 7) { return this.pages.slice(this.currentPage - 2, this.currentPage + 1); } // if currentPage more than 7 else if (this.currentPage > 7) { return this.pages.slice(this.currentPage - 4, this.currentPage + 1); } // if currentPage less than 4 else { return this.pages.slice(this.currentPage - 2, this.currentPage + 3); } } }, watch: { //how many pages to display items() { this.setPages(); } }, // create the array of items created() { this.getItems(); } });
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>VueJS分页-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号