結(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通過(guò)路由實(shí)現(xiàn)頁(yè)面間參數(shù)的傳遞
這篇文章主要介紹了Vue通過(guò)路由實(shí)現(xiàn)頁(yè)面間參數(shù)的傳遞,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-04-04
關(guān)于vue v-for 循環(huán)問(wèn)題(一行顯示四個(gè),每一行的最右邊那個(gè)計(jì)算屬性)
這篇文章主要介紹了關(guān)于vue v-for 循環(huán)問(wèn)題(一行顯示四個(gè),每一行的最右邊那個(gè)計(jì)算屬性),需要的朋友可以參考下2018-09-09
Vue3中同時(shí)定義多個(gè)插槽的實(shí)現(xiàn)示例
本文主要介紹了Vue3中同時(shí)定義多個(gè)插槽的實(shí)現(xiàn)示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-12-12
Vuex 在Vue 組件中獲得Vuex 狀態(tài)state的方法
今天小編就為大家分享一篇Vuex 在Vue 組件中獲得Vuex 狀態(tài)state的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-08-08

