亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

vue實(shí)現(xiàn)簡(jiǎn)單分頁功能

 更新時(shí)間:2022年03月04日 10:11:33   作者:斜影梧桐  
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)簡(jiǎn)單分頁功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue實(shí)現(xiàn)簡(jiǎn)單的分頁功能的具體代碼,供大家參考,具體內(nèi)容如下

<template>
<div id="pages">
? ? <div class="pages">
? ? ? ? <div class="classInfo" v-for="(item,index) in currentPageData" :key="index">
? ? ? ? ? ? {{item}}
? ? ? ? </div>
? ? ? ? <div class="img1" @click="prevPage()"></div>
? ? ? ? <div class="img2" @click="nextPage()"></div>
? ? </div>
</div>
</template>
<script>
export default {
? ? data () {
? ? ? ? return {
? ? ? ? ? ? totalPage: 1, //所有頁數(shù),默認(rèn)為1
? ? ? ? ? ? currentPage: 1, // 當(dāng)前頁數(shù),默認(rèn)為1
? ? ? ? ? ? pageSize: 9, //每頁顯示條數(shù)
? ? ? ? ? ? classInfo: [11,12,13,14,15,16,17,18,19,1,2,3,4,5,6,5,6,11,7,8,9,5,4,5,4,5], ?//頁面數(shù)據(jù)
? ? ? ? ? ? currentPageData: [] ?// 當(dāng)前頁顯示內(nèi)容
? ? ? ? }
? ? },
? ? mounted(){
? ? ? ? // 計(jì)算一共有幾頁
? ? ? ? this.totalPage = Math.ceil(this.classInfo.length / this.pageSize)
? ? ? ? // 計(jì)算得0時(shí)設(shè)置為1
? ? ? ? this.totalPage = this.totalPage == 0 ? 1:this.totalPage
? ? ? ? this.setCurrentPageData();
? ? },
? ? methods: {
? ? ? ? // 設(shè)置當(dāng)前頁面數(shù)據(jù)
? ? ? ? setCurrentPageData(){
? ? ? ? ? ? let begin = (this.currentPage - 1) * this.pageSize;
? ? ? ? ? ? let end = this.currentPage * this.pageSize;
? ? ? ? ? ? // console.log(begin)
? ? ? ? ? ? // console.log(end)
? ? ? ? ? ? this.currentPageData = this.classInfo.slice(
? ? ? ? ? ? ? ? begin,
? ? ? ? ? ? ? ? end
? ? ? ? ? ? )
? ? ? ? ? ? // console.log(this.currentPageData)
? ? ? ? },
? ? ? ? // 上一頁
? ? ? ? prevPage(){
? ? ? ? ? ? // console.log(this.currentPage)
? ? ? ? ? ? if(this.curentPage == 1) return
? ? ? ? ? ? this.currentPage--;
? ? ? ? ? ? this.setCurrentPageData();
? ? ? ? },
? ? ? ? // 下一頁
? ? ? ? nextPage(){
? ? ? ? ? ? // console.log(this.currentPage)
? ? ? ? ? ? if(this.curentPage == this.totalPage) return

? ? ? ? ? ? this.currentPage++
? ? ? ? ? ? this.setCurrentPageData()
? ? ? ? }
? ? }
}
</script>
<style lang="less" scoped>
#pages{
? ? // background-color: #fff;
? ? .pages{
? ? ? ? margin: 0 auto;
? ? ? ? width: 600px;
? ? ? ? height: 600px;
? ? ? ? // background-color: rgb(64, 180, 80);
? ? ? ? z-index: 999;
? ? ? ? .classInfo{
? ? ? ? ? ? font-size: 25px;
? ? ? ? ? ? color: aliceblue;
? ? ? ? ? ? z-index: 999;
? ? ? ? }
? ? ? ? .img1{
? ? ? ? ? ? width: 150px;
? ? ? ? ? ? height: 50px;
? ? ? ? ? ? background-color: rgb(189, 111, 111);
? ? ? ? }
? ? ? ? .img2{
? ? ? ? ? ? width: 150px;
? ? ? ? ? ? height: 50px;
? ? ? ? ? ? background-color: rgb(41, 94, 110);
? ? ? ? }
? ? }
}
</style>

效果圖:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue發(fā)送ajax請(qǐng)求詳解

    vue發(fā)送ajax請(qǐng)求詳解

    如何利用vue進(jìn)行AJAX,其它vue本身不支持發(fā)送AJAX請(qǐng)求,需要使用vue-resource(vue1.0版本)或axios(vue2.0版本)第三方插件的支持才行
    2018-10-10
  • Vue3中v-model語法糖的三種寫法詳解

    Vue3中v-model語法糖的三種寫法詳解

    這篇文章主要為大家詳細(xì)介紹了Vue3中v-model語法糖的三種寫法,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,有需要的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2024-01-01
  • 關(guān)于antd中select搜索框改變搜索值的問題

    關(guān)于antd中select搜索框改變搜索值的問題

    這篇文章主要介紹了關(guān)于antd中select搜索框改變搜索值的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • vue?el-pagination分頁查詢封裝的示例代碼

    vue?el-pagination分頁查詢封裝的示例代碼

    本文主要介紹了vue?el-pagination分頁查詢封裝的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-06-06
  • vue使用keep-alive后從部分頁面進(jìn)入不緩存示例詳解

    vue使用keep-alive后從部分頁面進(jìn)入不緩存示例詳解

    這篇文章主要給大家介紹了關(guān)于vue使用keep-alive后從部分頁面進(jìn)入不緩存的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用vue具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2023-03-03
  • Vue 中指令v-bind動(dòng)態(tài)綁定及與v-for結(jié)合使用詳解

    Vue 中指令v-bind動(dòng)態(tài)綁定及與v-for結(jié)合使用詳解

    這篇文章主要為大家介紹了Vue 中指令v-bind動(dòng)態(tài)綁定及與v-for結(jié)合使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-09-09
  • 手把手教你Vue3?按需引入?Echarts的過程(收藏)

    手把手教你Vue3?按需引入?Echarts的過程(收藏)

    新項(xiàng)目采用?Vue3?作為前端項(xiàng)目框架,避免不了要使用?echarts,但是在使用的時(shí)候,出現(xiàn)了與?Vue2?使用不一樣的地方,所以特別記下來,希望給到有需要的同學(xué)一些幫助
    2023-10-10
  • Vue.js結(jié)合bootstrap實(shí)現(xiàn)分頁控件

    Vue.js結(jié)合bootstrap實(shí)現(xiàn)分頁控件

    這篇文章主要為大家詳細(xì)介紹了Vue.js 合bootstrap實(shí)現(xiàn)分頁控件的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • Vue.js項(xiàng)目部署到服務(wù)器的詳細(xì)步驟

    Vue.js項(xiàng)目部署到服務(wù)器的詳細(xì)步驟

    這篇文章給大家介紹了Vue.js項(xiàng)目部署到服務(wù)器的詳細(xì)步驟,既然是部署到服務(wù)器,肯定是需要一個(gè)云的。具體思路步驟大家可以參考下本文
    2017-07-07
  • vue-router 路由傳參用法實(shí)例分析

    vue-router 路由傳參用法實(shí)例分析

    這篇文章主要介紹了vue-router 路由傳參用法,結(jié)合實(shí)例形式分析了vue-router 路由傳參基本使用方法及操作注意事項(xiàng),需要的朋友可以參考下
    2020-03-03

最新評(píng)論