How to use mescroll+ajax in vue to achieve pull-up, load, pull-down refresh?

how to use mescroll+ajax to implement pull-up, load, pull-down refresh. The example given on the official website of mescroll is not detailed at all.
I tried to paste the example given on the official website into vue, but I always reported an error.
< template >

<!--  -->
<!-- <page-header></page-header> -->
<!--  -->
<div class="container">
  <div id="mescroll" class="mescroll">
    <!---->
    <!-- <img src="img/beibei1.jpg"/>
        <img src="img/beibei2.jpg"/> -->
    <!---->
    <ul id="dataList" class="data-list">
      <!--<li>
                <img class="pd-img" src="../res/img/pd1.jpg"/>
                <p class="pd-name">

<p class="pd-price">200.00

<p class="pd-sold">50

</li>--> </ul> </div> </div> <!-- --> <!-- <page-footer></page-footer> -->

< / div >
< / template >
< script >
import MeScroll from "mescroll.js"
import" mescroll.js/mescroll.min.css"

/ / Public

export default {

name: "signin",
// 
//   mixins: [share],
data() {
  return {
    msg: "signin",
    user: {}
  }
},
methods: {
  downCallback() {
    //..
    //...
    //
    this.getListDataFromNet(0, 1, function (data) {
      //,
      mescroll.endSuccess();
      //
      setListData(data, false);
    }, function () {
      //,
      mescroll.endErr();
    });
  },
  upCallback(page) {
    //
    this.getListDataFromNet(page.num, page.size, function (curPageData) {
      //,;
      //mescroll,,;,;
      console.log("page.num=" + page.num + ", page.size=" + page.size + ", curPageData.length=" + curPageData.length);

      //():  totalPage
      //mescroll.endByPage(curPageData.length, totalPage); //(, )

      //():  totalSize
      //mescroll.endBySize(curPageData.length, totalSize); //(, )

      //():  hasNext
      //mescroll.endSuccess(curPageData.length, hasNext); //(, true/false)

      // (),:20,10,2.,,hasNext,.
      mescroll.endSuccess(curPageData.length);

      //
      setListData(curPageData, true);
    }, function () {
      //,
      mescroll.endErr();
    });
  },
  setListData(curPageData, isAppend) {
    var listDom = document.getElementById("dataList");
    for (var i = 0; i < curPageData.length; iPP) {
      var pd = curPageData[i];

      var str = "<img class="pd-img" src="" + pd.pdImg + ""/>";
      str += "<p class="pd-name">" + pd.pdName + "

"; str += "<p class="pd-price">" + pd.pdPrice + "

"; str += "<p class="pd-sold">" + pd.pdSold + "

"; var liDom = document.createElement("li"); liDom.innerHTML = str; if (isAppend) { listDom.appendChild(liDom); //, } else { listDom.insertBefore(liDom, listDom.firstChild); //, } } }, getListDataFromNet(pageNum, pageSize, successCallback, errorCallback) { //, setTimeout(function () { $.ajax({ type: "GET", url: "../../static/js/students.json", // url: "../res/pdlist1.json?num="+pageNum+"&size="+pageSize, dataType: "json", success: function (data) { var listData = []; if (pageNum == 0) { // var i = Math.floor(Math.random() * data.length); // data[i].pdName = " "; listData.push(data[i]); } else { // () for (var i = (pageNum - 1) * pageSize; i < pageNum * pageSize; iPP) { if (i == data.length) break; listData.push(data[i]); } } // successCallback(listData); }, error: errorCallback }); }, 2000) } }, mounted() { //MeScroll,down,, //: mescroll.resetUpScroll(); resetUpScrollpage.num=1,up.callback,; var self = this; self.mescroll = new MeScroll("mescroll", { //vuemountedmescroll,id down: { auto: false, //callback; true callback: this.downCallback // }, up: { auto: true, //, isBoth: true, //,;false,; true,; callback: this.upCallback, // isBounce: false, //ios,(,): http://www.mescroll.com/qa.html-sharpq10 toTop: { // // src: "../res/img/mescroll-totop.png", //1000px,offset //offset : 1000 } } }); this.downCallback() // this.downCallback() }, // created() { this.getListDataFromNet() }

}
< / script >
< style scoped >

< / style >

clipboard.png
ask the boss to give us some advice

Mar.21,2021

you put the initialization code into the nextTick function to try, and then you do not define the variable mescroll, you will be damned if you don't report an error. You should add this


before your mescroll.

have you tried upstairs. You hang mescroll on VM when you mounted, but you don't use this, when you call it, and you're not an arrow function, so this doesn't point to VM, so you have to cache this, before you use it.

clipboard.png


simply encapsulates a component for reference

Source code: https://github.com/yimogit/vu.

Preview: ide/04-vue-components/vue%2Bmescroll%3DVScrollFull.html" rel=" nofollow noreferrer "> https://vue-doc.yimo.link/gui.


successCallback reports an error and replace it with this callback method to see successCallback&&successCallback (listData);

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb2f45-481fa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb2f45-481fa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?