色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術(shù)文章
文章詳情頁

vue+iview實(shí)現(xiàn)分頁及查詢功能

瀏覽:4日期:2022-10-26 11:34:56

vue+iview 分頁及刪、查功能實(shí)現(xiàn)

首先要想實(shí)現(xiàn)分頁功能必須得知道 當(dāng)前頁碼、每頁大小、總數(shù)目。

iview對(duì)分頁的功能支持還是很強(qiáng)大的,有很多鉤子函數(shù)

具體實(shí)現(xiàn)看后端返回的數(shù)據(jù)

<template> <div v-if='this.$store.state.user.userType == 0 || this.$store.state.user.userType == 1'> <Input type='text' search enter-button placeholder='根據(jù)施工人員姓名查找' v-model='peopleName' @input='search'/> <Table :columns='peopleCol' :data='peopleDat'></Table> <!--通過sync修飾符可以動(dòng)態(tài)獲取頁碼--> <Page :total='dataCount' :current.sync='current' :page-size='pageSize' show-total @on-change='changePage'></Page> <!--該modal是刪除提醒框--> <Modal v-model='confirmDelete' width='360'> <p slot='header' style='color:#f60;text-align:center'> <Icon type='ios-information-circle'></Icon> <span>刪除確認(rèn)</span> </p> <div style='text-align:center'> <p>此操作不可恢復(fù),確定要?jiǎng)h除嗎?</p> </div> <div slot='footer'> <Button size='large' @click='cancelDelete'>取消</Button> <Button type='error' size='large' @click='deleteConfirm'>刪除</Button> </div> </Modal> </div></template><script> export default { components: { addWorker, updateWorker }, data () { return { selectedID:’’,//刪除選中的ID confirmDelete:false,//刪除提示框 current:1, isShow:false, selectedList:{},//選中施工人員的id值 peopleName:’’, dataCount:0,//總條數(shù) pageSize:2,//每頁顯示數(shù)據(jù)條數(shù) peopleDat: [], peopleCol: [ { title: ’操作’, key: ’action’, width: 120, render: (h, params) => { return h(’Button’, { props: { type: ’error’, size: ’small’ }, on:{ click: ()=>{ this.confirmDelete=true this.delete(params.row.peopleID) } }}, ’刪除’) } } ], } }, mounted() { this.getWorkerList() }, methods:{ getWorkerList(){//組件初始化顯示的數(shù)據(jù) const currPage=1 const pageSize=this.pageSize //下面是向后臺(tái)發(fā)送請(qǐng)求 setTimeout(async()=>{ const r=await getWorkers(currPage,pageSize) if(r.data.success){ this.dataCount=r.data.list.count//初始化總條數(shù) this.peopleDat=r.data.list.data//默認(rèn)頁列表渲染數(shù)據(jù) console.log(r) } }) }, changePage(index){//頁碼改變觸發(fā)的函數(shù) //index當(dāng)前頁碼 const currPage=index const pageSize=this.pageSize setTimeout(async ()=>{ const r=await changePage(currPage,pageSize) if(r.data.success){ this.peopleDat=r.data.list.data//當(dāng)前頁列表數(shù)據(jù) } }) }, search(){ const peopleName=this.peopleName const pageSize=this.pageSize setTimeout(async()=>{ const r=await search(peopleName,pageSize) if(r.data.success){ this.peopleDat=r.data.list.data this.dataCount=r.data.list.count//如果不設(shè)置總條數(shù)那么當(dāng)精確查詢時(shí)每頁都會(huì)有數(shù)據(jù)這得看后端返回的數(shù)據(jù)有沒有這些數(shù)據(jù) } else { this.$Message.warning(’查詢失敗!’) } }) }, delete(peopleID){ this.selectedID=peopleID }, deleteConfirm(){ const id=this.selectedID setTimeout(async ()=>{ const r=await deleteWorker(id) if(r.data.success){ //這里做的一個(gè)功能是當(dāng)你刪除某頁數(shù)據(jù)后立即刷新當(dāng)前頁的數(shù)據(jù) this.changePage(this.current)//更新當(dāng)前頁碼的數(shù)據(jù) this.$Message.success(’刪除成功!’) } else{ this.$Message.warning(’刪除失敗!’) } }) this.confirmDelete=false }, cancelDelete(){ this.confirmDelete=false this.$Message.info(’你取消了刪除操作’) } } }</script><style scoped> .paging{ float:left; margin-top:10px; }</style>

關(guān)于vue.js的學(xué)習(xí)教程,請(qǐng)大家點(diǎn)擊專題vue.js組件學(xué)習(xí)教程、Vue.js前端組件學(xué)習(xí)教程進(jìn)行學(xué)習(xí)。

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

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 97se狠狠狠狠狠亚洲综合网 | 99久久精品国产亚洲 | 毛片大片免费看 | 国产成人精品视频一区二区不卡 | 91久久99| 欧毛片| 美女张开大腿让男人捅 | 免费黄色三级网站 | 日本一区二区三区不卡视频中文字幕 | 欧美性视频xxxxxxxx | 白白在线观看永久免费视频 | 日本一区二区三区四区五区 | 一区二区三区在线播放视频 | 美女张开腿让男人捅的视频 | 成人影院欧美大片免费看 | 九九热视频在线播放 | 天堂素人搭讪系列嫩模在线观看 | 麻豆19禁国产青草精品 | 欧美aaa性bbb毛片 | 青青草国产一区二区三区 | 久久精品国产线看观看亚洲 | 韩国美女一级片 | 日本三级网站在线观看 | 成人欧美 | 国产精品亚洲精品不卡 | 亚洲视频在线观看免费视频 | 国产片91人成在线观看 | 亚洲a级 | 亚洲国产成人久久精品影视 | 成人毛片免费观看视频大全 | 久久的精品99精品66 | 国产精品一区二区手机在线观看 | 日本一在线中文字幕天堂 | 中文字幕亚洲在线 | 国产精自产拍久久久久久 | 日本三级中文字幕 | 天堂视频免费看 | 最新亚洲人成网站在线影院 | 日韩高清欧美 | 亚洲 欧美 国产 日韩 制服 bt | 日韩一级a毛片欧美一级 |