最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue2滾動條加載更多數(shù)據(jù)實現(xiàn)代碼

 更新時間:2017年01月10日 16:38:34   作者:sherryChang  
本篇文章主要介紹了vue2滾動條加載更多數(shù)據(jù)實現(xiàn)代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

解析:

判斷滾動條到底部,需要用到DOM的三個屬性值,即scrollTop、clientHeight、scrollHeight。

scrollTop為滾動條在Y軸上的滾動距離。

clientHeight為內容可視區(qū)域的高度。

scrollHeight為內容可視區(qū)域的高度加上溢出(滾動)的距離。

從這個三個屬性的介紹就可以看出來,滾動條到底部的條件即為scrollTop + clientHeight == scrollHeight。(兼容不同的瀏覽器)。

代碼:

1.vue的實現(xiàn)

html:

<div class="questionList-content-list">
   <ul>
    <li v-for="item in questionListData" @click="goDetail(item.id)">
     {{item.create_time}}
     [{{item.level_value}}]
    {{item.description}}
     {{item.status_value}}
    </li>
   </ul>
  </div>

js:

created () {
   var self = this
   $(window).scroll(function () {
    let scrollTop = $(this).scrollTop()
    let scrollHeight = $(document).height()
    let windowHeight = $(this).height()
    if (scrollTop + windowHeight === scrollHeight) {
     self.questionListData.push({
      'id': '62564AED8A4FA7CCDBFBD0F9A11C97A8',
      'type': '0102',
      'type_value': '數(shù)據(jù)問題',
      'description': '撒的劃分空間撒電話費看見愛上對方見客戶速度快解放哈薩克接電話發(fā)生的劃分空間是的哈副科級哈師大空間劃分可接受的后方可摳腳大漢房間卡收到貨放假多少',
      'status': '0',
      'status_value': '未解決',
      'level': '0203',
      'level_value': '高',
      'content': '過好幾個號',
      'userid': 'lxzx_hdsx',
      'create_time': 1480296174000,
      'images': null
     })
     self.questionListData.push({
      'id': 'D679611152737E675984D7681BC94F16',
      'type': '0101',
      'type_value': '需求問題',
      'description': 'a阿斯頓發(fā)生豐盛的范德薩范德薩發(fā)十多個非官方阿道夫葛根粉v跟下載v',
      'status': '0',
      'status_value': '未解決',
      'level': '0203',
      'level_value': '高',
      'content': '秩序性支出V型從v',
      'userid': 'lxzx_hdsx',
      'create_time': 1480296155000,
      'images': null
     })
     self.questionListData.push({
      'id': 'B5C61D990F962570C34B8EE607CA1384',
      'type': '0104',
      'type_value': '頁面問題',
      'description': '回復的文本框和字體有點丑',
      'status': '0',
      'status_value': '未解決',
      'level': '0203',
      'level_value': '高',
      'content': '回復的文本框和字體有點丑',
      'userid': 'lxzx_hdsx',
      'create_time': 1480064620000,
      'images': null
     })
     self.questionListData.push({
      'id': '279F9571CB8DC36F1DEA5C8773F1793C',
      'type': '0103',
      'type_value': '設計問題',
      'description': '設計bug,不應該這樣設計。',
      'status': '0',
      'status_value': '未解決',
      'level': '0204',
      'level_value': '非常高',
      'content': '設計bug,不應該這樣設計。你看。',
      'userid': 'lxzx_hdsx',
      'create_time': 1480064114000,
      'images': null
     })
     self.questionListData.push({
      'id': '80E365710CB9157DB24F08C8D2039473',
      'type': '0102',
      'type_value': '數(shù)據(jù)問題',
      'description': '數(shù)據(jù)列表滾動條問題',
      'status': '0',
      'status_value': '未解決',
      'level': '0202',
      'level_value': '中',
      'content': '數(shù)據(jù)列表在數(shù)據(jù)條數(shù)比較多的情況下無滾動條',
      'userid': 'lxzx_hdsx',
      'create_time': 1480034606000,
      'images': null
     })
     console.log(self.questionListData)
    }
   })
  },

因為vue2 實現(xiàn)了m-v雙向綁定,所以這里直接改變for循環(huán)數(shù)據(jù)源即可實現(xiàn)列表的數(shù)據(jù)刷新;

2: 普通js的實現(xiàn)

html:

<div id="content" style="height:960px" class="questionList-content-list"> 
  <ul> 
    <li class="list"> 
   <span測試1</span>
     <span>測試2</span>
     <span>測試3</span>
     <span>測試4</span>
     <span>測試5</span>
     <span>測試6</span>
     <span>測試7</span>
     <span>測試8</span>
     <span>測試9</span>
     <span>測試10</span>
     <span>測試11</span>
    </li> 
  </ul> 
</div>

js:

var html = ''       //距下邊界長度/單位px
  $(window).scroll(function () {
   var scrollTop = $(this).scrollTop();
   var scrollHeight = $(document).height();
   var windowHeight = $(this).height();
   if (scrollTop + windowHeight == scrollHeight) {
    for(let i=0;i<10;i++){
     html += '<li>Page: ' + i + ', Data Index: ' + i + ' </li>'
    }
    $('#content ul').append(html);
   }
  });

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論

泽州县| 河池市| 淮阳县| 湖北省| 郯城县| 若羌县| 无为县| 山东省| 砀山县| 松江区| 荆州市| 长寿区| 基隆市| 西乌珠穆沁旗| 普宁市| 罗城| 韶山市| 平罗县| 呼和浩特市| 老河口市| 延寿县| 洞口县| 江都市| 婺源县| 阿瓦提县| 徐汇区| 罗田县| 将乐县| 隆林| 昂仁县| 广元市| 平邑县| 澄江县| 耿马| 拉萨市| 洛隆县| 灵璧县| 株洲市| 民乐县| 长葛市| 淮北市|