vue+elementUI實(shí)現(xiàn)分頁(yè)效果
本文實(shí)例為大家分享了vue+elementUI實(shí)現(xiàn)分頁(yè)效果的具體代碼,供大家參考,具體內(nèi)容如下
頁(yè)面中渲染的數(shù)據(jù)不是所有數(shù)據(jù),是需要展示的數(shù)據(jù),即當(dāng)前頁(yè)的數(shù)據(jù),默認(rèn)第一頁(yè)的數(shù)據(jù),這里為showDate
template中代碼段(渲染數(shù)據(jù))
<div style="height:76vh;margin-top:1%"> ? ? ? ? ? ? <el-table :data="showData" ? ? ? ? ? ? ? ? ? ? ? style="width: 100%" ? ? ? ? ? ? ? ? ? ? ? :header-cell-style="headClass"> ? ? ? ? ? ? ? ? <el-table-column type="index" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?label="編號(hào)" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?width="80" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?header-align="center" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?align="center"></el-table-column> ? ? ? ? ? ? ? ? <el-table-column prop="name" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?label="企業(yè)名稱(chēng)" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?width="180" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?header-align="center" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?align="center"></el-table-column> ? ? ? ? ? ? ? ? <el-table-column prop="date" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?label="注冊(cè)時(shí)間" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?width="150" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?header-align="center" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?align="center"></el-table-column> ? ? ? ? ? ? ? ? <el-table-column prop="publishNumber" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?label="發(fā)布崗位數(shù)量" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?width="130" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?header-align="center" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?align="center"></el-table-column> ? ? ? ? ? ? ? ? <el-table-column prop="checkTimes" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?label="查看簡(jiǎn)歷次數(shù)" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?width="130" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?header-align="center" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?align="center"></el-table-column> ? ? ? ? ? ? ? ? <el-table-column prop="companyStatus" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?label="崗位發(fā)布權(quán)限" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?width="130" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?header-align="center" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?align="center"> ? ? ? ? ? ? ? ? ? ? <template slot-scope="scope"> ? ? ? ? ? ? ? ? ? ? ? ? <span v-if="scope.row.companyStatus == 1">否</span> ? ? ? ? ? ? ? ? ? ? ? ? <span v-else-if="scope.row.companyStatus == 0">是</span> ? ? ? ? ? ? ? ? ? ? </template> ? ? ? ? ? ? ? ? </el-table-column> ? ? ? ? ? ? ? ? <el-table-column prop="companyStatus" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?label="查看人才權(quán)限" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?width="130" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?header-align="center" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?align="center"> ? ? ? ? ? ? ? ? ? ? <template slot-scope="scope"> ? ? ? ? ? ? ? ? ? ? ? ? <span v-if="scope.row.companyStatus == 1">否</span> ? ? ? ? ? ? ? ? ? ? ? ? <span v-else-if="scope.row.companyStatus == 0">是</span> ? ? ? ? ? ? ? ? ? ? </template> ? ? ? ? ? ? ? ? </el-table-column> ? ? ? ? ? ? ? ? ? <el-table-column prop="RecruitmentTimes" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?label="現(xiàn)場(chǎng)招聘次數(shù)" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?width="130" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?header-align="center" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?align="center"></el-table-column> ? ? ? ? ? ? ? ? ? <el-table-column prop="windowPublishTimes" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?label="櫥窗發(fā)布次數(shù)" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?width="130" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?header-align="center" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?align="center"></el-table-column> ? ? ? ? ? ? ? ? ? <el-table-column prop="companyStatus" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?label="企業(yè)狀態(tài)" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?width="130" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?header-align="center" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?align="center"> ? ? ? ? ? ? ? ? ? ? <template slot-scope="scope"> ? ? ? ? ? ? ? ? ? ? ? ? <span v-if="scope.row.companyStatus == 1" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? style="color: #1ec6df">啟用</span> ? ? ? ? ? ? ? ? ? ? ? ? <span v-else-if="scope.row.companyStatus == 0" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? style="color: #df721e">禁用</span> ? ? ? ? ? ? ? ? ? ? </template> ? ? ? ? ? ? ? ? </el-table-column> ? ? ? ? ? ? ? ? ? <el-table-column fixed="right" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?label="操作" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?width="280"> ? ? ? ? ? ? ? ? ? ? ? <template> ? ? ? ? ? ? ? ? ? ? ? ? <el-link :underline="false" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?href="#" rel="external nofollow" rel="external nofollow" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?class="alink">崗位列表</el-link> ? ? ? ? ? ? ? ? ? ? ? ? <el-link :underline="false" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?href="#" rel="external nofollow" rel="external nofollow" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?class="alink">開(kāi)通記錄</el-link> ? ? ? ? ? ? ? ? ? ? </template> ? ? ? ? ? ? ? ? </el-table-column> ? ? ? </el-table> </div>
template中代碼段(分頁(yè)部分,與上一段代碼同層級(jí))
<div class="block"> ? ? ? ? ? ? <el-pagination :page-size="pagesize" ? ? ? ? ? ? ? ? ? ? ? ? ? ?:current-page="currentPage" ? ? ? ? ? ? ? ? ? ? ? ? ? ?layout="prev, pager, next" ? ? ? ? ? ? ? ? ? ? ? ? ? ?:total="companyData.length" ? ? ? ? ? ? ? ? ? ? ? ? ? ?@current-change="handleCurrentChange" ? ? ? ? ? ? ? ? ? ? ? ? ? ?@prev-click="upChange" ? ? ? ? ? ? ? ? ? ? ? ? ? ?@next-click="nextChange" ? ? ? ? ? ? ? ? ? ? ? ? ? ?style="text-align: center;"> ? ? ? ? </el-pagination> </div>
下面是邏輯實(shí)現(xiàn)
1.定義數(shù)組
2.初始化賦值第一頁(yè)的數(shù)據(jù)
slice()
<script> export default { ? ? //頁(yè)面第一次加載 顯示的數(shù)據(jù) ? ? created() { ? ? ? ? this.showData = this.companyData.slice(0, this.pagesize); ? ? ? ? console.log("顯示的數(shù)據(jù)"); ? ? ? ? console.log(this.showData); ? ? }, ? ? data() { ? ? ? ? return { ? ? ? ? ? ? // 企業(yè)名稱(chēng) ? ? ? ? ? ? companyName: "", ? ? ? ? ? ? showData: [], //顯示的數(shù)據(jù) ? ? ? ? ? ? pagesize: 3, //一頁(yè)的數(shù)據(jù)條數(shù) ? ? ? ? ? ? currentPage: 1, //當(dāng)前頁(yè)是從哪頁(yè)開(kāi)始 ? ? ? ? ? ? companyData: [ ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? name: "企業(yè)名稱(chēng)1", ? ? ? ? ? ? ? ? ? ? date: "2016-05-04", ? ? ? ? ? ? ? ? ? ? publishNumber: 12, ? ? ? ? ? ? ? ? ? ? checkTimes: 10, ? ? ? ? ? ? ? ? ? ? RecruitmentTimes: 110, ? ? ? ? ? ? ? ? ? ? windowPublishTimes: 120, ? ? ? ? ? ? ? ? ? ? companyStatus: 0, ? ? ? ? ? ? ? ? }, ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? name: "企業(yè)名稱(chēng)2", ? ? ? ? ? ? ? ? ? ? date: "2016-05-04", ? ? ? ? ? ? ? ? ? ? publishNumber: 12, ? ? ? ? ? ? ? ? ? ? checkTimes: 10, ? ? ? ? ? ? ? ? ? ? RecruitmentTimes: 110, ? ? ? ? ? ? ? ? ? ? windowPublishTimes: 120, ? ? ? ? ? ? ? ? ? ? companyStatus: 0, ? ? ? ? ? ? ? ? }, ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? name: "企業(yè)名稱(chēng)3", ? ? ? ? ? ? ? ? ? ? date: "2016-05-04", ? ? ? ? ? ? ? ? ? ? publishNumber: 12, ? ? ? ? ? ? ? ? ? ? checkTimes: 10, ? ? ? ? ? ? ? ? ? ? RecruitmentTimes: 110, ? ? ? ? ? ? ? ? ? ? windowPublishTimes: 120, ? ? ? ? ? ? ? ? ? ? companyStatus: 1, ? ? ? ? ? ? ? ? }, ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? name: "企業(yè)名稱(chēng)4", ? ? ? ? ? ? ? ? ? ? date: "2016-05-04", ? ? ? ? ? ? ? ? ? ? publishNumber: 12, ? ? ? ? ? ? ? ? ? ? checkTimes: 10, ? ? ? ? ? ? ? ? ? ? RecruitmentTimes: 110, ? ? ? ? ? ? ? ? ? ? windowPublishTimes: 120, ? ? ? ? ? ? ? ? ? ? companyStatus: 1, ? ? ? ? ? ? ? ? }, ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? name: "企業(yè)名稱(chēng)5", ? ? ? ? ? ? ? ? ? ? date: "2016-05-04", ? ? ? ? ? ? ? ? ? ? publishNumber: 12, ? ? ? ? ? ? ? ? ? ? checkTimes: 10, ? ? ? ? ? ? ? ? ? ? RecruitmentTimes: 110, ? ? ? ? ? ? ? ? ? ? windowPublishTimes: 120, ? ? ? ? ? ? ? ? ? ? companyStatus: 1, ? ? ? ? ? ? ? ? }, ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? name: "企業(yè)名稱(chēng)6", ? ? ? ? ? ? ? ? ? ? date: "2016-05-04", ? ? ? ? ? ? ? ? ? ? publishNumber: 12, ? ? ? ? ? ? ? ? ? ? checkTimes: 10, ? ? ? ? ? ? ? ? ? ? RecruitmentTimes: 110, ? ? ? ? ? ? ? ? ? ? windowPublishTimes: 120, ? ? ? ? ? ? ? ? ? ? companyStatus: 1, ? ? ? ? ? ? ? ? }, ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? name: "企業(yè)名稱(chēng)7", ? ? ? ? ? ? ? ? ? ? date: "2016-05-04", ? ? ? ? ? ? ? ? ? ? publishNumber: 12, ? ? ? ? ? ? ? ? ? ? checkTimes: 10, ? ? ? ? ? ? ? ? ? ? RecruitmentTimes: 110, ? ? ? ? ? ? ? ? ? ? windowPublishTimes: 120, ? ? ? ? ? ? ? ? ? ? companyStatus: 1, ? ? ? ? ? ? ? ? }, ? ? ? ? ? ? ], ? ? ? ? }; ? ? }, ? ? methods: { ? ? ? ? //選擇頁(yè) ? ? ? ? handleCurrentChange(val) { ? ? ? ? ? ? this.currentPage = val; //動(dòng)態(tài)改變 ? ? ? ? ? ? this.showData = this.companyData.slice( ? ? ? ? ? ? ? ? (this.currentPage - 1) * this.pagesize, ? ? ? ? ? ? ? ? this.currentPage * this.pagesize ? ? ? ? ? ? ); ? ? ? ? }, ? ? ? ? //上一頁(yè) ? ? ? ? upChange(val) { ? ? ? ? ? ? console.log(val); ? ? ? ? ? ? this.currentPage -= 1; //動(dòng)態(tài)改變 ? ? ? ? ? ? this.showData = this.companyData.slice( ? ? ? ? ? ? ? ? (this.currentPage - 1) * this.pagesize, ? ? ? ? ? ? ? ? this.currentPage * this.pagesize ? ? ? ? ? ? ); ? ? ? ? }, ? ? ? ? //下一頁(yè) ? ? ? ? nextChange(val) { ? ? ? ? ? ? this.currentPage += 1; //動(dòng)態(tài)改變 ? ? ? ? ? ? this.showData = this.companyData.slice( ? ? ? ? ? ? ? ? (this.currentPage - 1) * this.pagesize, ? ? ? ? ? ? ? ? this.currentPage * this.pagesize ? ? ? ? ? ? ); ? ? ? ? }, ? ? ? }, }; </script>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Vue+ElementUI?實(shí)現(xiàn)分頁(yè)功能-mysql數(shù)據(jù)
- Vue2.0+ElementUI+PageHelper實(shí)現(xiàn)的表格分頁(yè)功能
- Vue組件庫(kù)ElementUI實(shí)現(xiàn)表格列表分頁(yè)效果
- Vue中ElementUI分頁(yè)組件Pagination的使用方法
- 詳解vue修改elementUI的分頁(yè)組件視圖沒(méi)更新問(wèn)題
- vue+elementUI組件table實(shí)現(xiàn)前端分頁(yè)功能
- Vue+ElementUI table實(shí)現(xiàn)表格分頁(yè)
- vue iview實(shí)現(xiàn)分頁(yè)功能
- Vue分頁(yè)組件的封裝方法
- vue實(shí)現(xiàn)web滾動(dòng)條分頁(yè)
相關(guān)文章
vue.js父子組件通信動(dòng)態(tài)綁定的實(shí)例
今天小編就為大家分享一篇vue.js父子組件通信動(dòng)態(tài)綁定的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-09-09vue-router相關(guān)基礎(chǔ)知識(shí)及工作原理
這篇文章主要介紹了vue-router相關(guān)基礎(chǔ)知識(shí)及單頁(yè)面應(yīng)用的工作原理,需要的朋友可以參考下2018-03-03Vue?props傳入function時(shí)的this指向問(wèn)題解讀
這篇文章主要介紹了Vue?props傳入function時(shí)的this指向問(wèn)題解讀,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-01-01vue使用Vue.extend創(chuàng)建全局toast組件實(shí)例
這篇文章主要介紹了vue使用Vue.extend創(chuàng)建全局toast組件實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-03-03vue中實(shí)現(xiàn)Monaco Editor自定義提示功能
最近小編接到一個(gè)項(xiàng)目,需要在瀏覽器的ide中支持自定義提示功能,接下來(lái)通過(guò)本文給大家介紹在vue中實(shí)現(xiàn)Monaco Editor自定義提示功能,需要的朋友可以參考下2019-07-07