結合mint-ui移動端下拉載入實踐方法總結,mint-ui下拉

來源:互聯網
上載者:User

結合mint-ui移動端下拉載入實踐方法總結,mint-ui下拉

1.npm i mint-ui -S

2.main.js中引入import 'mint-ui/lib/style.css'

3.以下是代碼結構部分:

<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為禁止上拉,就是不讓往上劃載入資料了  scrollMode:"auto", //移動端彈性滾動效果,touch為彈性滾動,auto是非彈性滾動  totalpage:0,  loading:false,  bottomText: '', } }, mounted(){ this.loadPageList(); //初次訪問查詢列表 }, methods:{ loadBottom:function() {  // 上拉載入  this.more();// 上拉觸發的分頁查詢  this.$refs.loadmore.onBottomLoaded();// 固定方法,查詢完要調用一次,用於重新置放 }, loadPageList:function (){  // 查詢資料  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 () {   // 是否還有下一頁,加個方法判斷,沒有下一頁要禁止上拉   this.scrollMode = "touch";   this.isHaveMore();  });  }); }, more:function (){  // 分頁查詢  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(){  // 是否還有下一頁,如果沒有就禁止上拉重新整理  //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>

以上這篇結合mint-ui移動端下拉載入實踐方法總結就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支援幫客之家。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.