結(jié)合mint-ui移動(dòng)端下拉加載實(shí)踐方法總結(jié)
1.npm i mint-ui -S
2.main.js中引入import 'mint-ui/lib/style.css'
3.以下是代碼結(jié)構(gòu)部分:
<template> <div class="main-body" :style="{'-webkit-overflow-scrolling': scrollMode}"> <v-loadmore :bottom-method="loadBottom" :bottom-all-loaded="allLoaded" :auto-fill="false" ref="loadmore"> <ul class="list"> <li v-for="(item, index) in proCopyright"> <div>{{item.FZD_ZPMC}}</div> </li> </ul> </v-loadmore> </div> </template> <script> import {Loadmore} from 'mint-ui'; export default { components:{ 'v-loadmore':Loadmore, }, data () { return { pageNo:1, pageSize:50, proCopyright:[], allLoaded: false, //是否可以上拉屬性,false可以上拉,true為禁止上拉,就是不讓往上劃加載數(shù)據(jù)了 scrollMode:"auto", //移動(dòng)端彈性滾動(dòng)效果,touch為彈性滾動(dòng),auto是非彈性滾動(dòng) totalpage:0, loading:false, bottomText: '', } }, mounted(){ this.loadPageList(); //初次訪問(wèn)查詢列表 }, methods:{ loadBottom:function() { // 上拉加載 this.more();// 上拉觸發(fā)的分頁(yè)查詢 this.$refs.loadmore.onBottomLoaded();// 固定方法,查詢完要調(diào)用一次,用于重新定位 }, loadPageList:function (){ // 查詢數(shù)據(jù) this.axios.get('/copyright?key='+ encodeURIComponent('公司名稱')+"&mask=001"+"&page="+this.pageNo+"&size="+this.pageSize).then(res =>{ console.log(res); this.proCopyright = res.data.result.PRODUCTCOPYRIGHT; this.totalpage = Math.ceil(res.data.result.COUNTOFPRODUCTCOPYRIGHT/this.pageSize); if(this.totalpage == 1){ this.allLoaded = true; } this.$nextTick(function () { // 是否還有下一頁(yè),加個(gè)方法判斷,沒(méi)有下一頁(yè)要禁止上拉 this.scrollMode = "touch"; this.isHaveMore(); }); }); }, more:function (){ // 分頁(yè)查詢 if(this.totalpage == 1){ this.pageNo = 1; this.allLoaded = true; }else{ this.pageNo = parseInt(this.pageNo) + 1; this.allLoaded = false; } console.log(this.pageNo); this.axios.get('/copyright?key='+ encodeURIComponent('公司名稱')+"&mask=001"+"&page="+this.pageNo+"&size="+this.pageSize).then(res=>{ this.proCopyright = this.proCopyright.concat(res.data.result.PRODUCTCOPYRIGHT); console.log(this.proCopyright); this.isHaveMore(); }); }, isHaveMore:function(){ // 是否還有下一頁(yè),如果沒(méi)有就禁止上拉刷新 //this.allLoaded = false; //true是禁止上拉加載 if(this.pageNo == this.totalpage){ this.allLoaded = true; } } }, } </script> <!-- Add "scoped" attribute to limit CSS to this component only --> <style scoped> li{ padding:30px 0; background-color: #ccc; margin-bottom:20px; } </style>
以上這篇結(jié)合mint-ui移動(dòng)端下拉加載實(shí)踐方法總結(jié)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Vue事件獲取事件對(duì)象之event.currentTarget詳解
這篇文章主要介紹了Vue事件獲取事件對(duì)象之event.currentTarget,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-03-03vue路由導(dǎo)航守衛(wèi)和請(qǐng)求攔截以及基于node的token認(rèn)證的方法
這篇文章主要介紹了vue路由導(dǎo)航守衛(wèi)和請(qǐng)求攔截以及基于node的token認(rèn)證的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2019-04-04el-form resetFields無(wú)效和validate無(wú)效的可能原因及解決方法
本文主要介紹了el-form resetFields無(wú)效和validate無(wú)效的可能原因及解決方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08vue實(shí)現(xiàn)select下拉顯示隱藏功能
這篇文章主要介紹了vue實(shí)現(xiàn)select下拉顯示隱藏功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-09-09Vue項(xiàng)目全局配置頁(yè)面緩存之按需讀取緩存的實(shí)現(xiàn)詳解
這篇文章主要給大家介紹了關(guān)于Vue項(xiàng)目全局配置頁(yè)面緩存之實(shí)現(xiàn)按需讀取緩存的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起看看吧2018-08-08vue中v-if和v-for一起使用的弊端及解決辦法(同時(shí)使用 v-if 和 v-for不
當(dāng) v-if 和 v-for 同時(shí)存在于一個(gè)元素上的時(shí)候,v-if 會(huì)首先被執(zhí)行,這篇文章主要介紹了vue中v-if和v-for一起使用的弊端及解決辦法,需要的朋友可以參考下2023-07-07