zoukankan      html  css  js  c++  java
  • Vue+jquery上拉加载

    <ul>
          <li class="new-list" v-for="item in proarr">
            <a :href="'/index.php/new/news?id='+item.id" class="new-item">
              <div class="new-title ell">{{item.title}}</div>
              <div class="new-content">
                <div class="new-cover" v-bind:style="{backgroundImage: 'url('+item.purl+')'}"></div>
                <div class="new-desc">{{item.introduction}}</div>
              </div>
              <div class="new-date">{{item.create_date}}</div>
            </a>
          </li>
        </ul>
      <div id="ajaxloading" v-show="showLoading" class="ac line-scale-pulse-out-rapid">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
      </div>
      <p class="errormsg ac orange pd20">{{errmsg}}</p>
    new Vue({
      el: '#app',
      data() {
        return {
          proarr: [],
          showLoading: false,
          p:1,
          errmsg:''
        };
      },
      components: {
      },
      created() {
        this.getProList();
        //监听滚动 window.addEventListener(
    'scroll', this.handleScroll); }, methods: { handleScroll() {
        //判断滚动到底部
    if ($(window).scrollTop() >=$(document).height() - $(window).height()) { this.showLoading = true; this.p++; this.getProList(this.p); } }, getProList() { var that = this; $.post('url',{p:this.p},function(datas){ var state = datas.sign; that.showLoading = false; if (state === ERROK) { var data = datas.data.data; for (var i = 0; i < data.length; i++) { that.proarr.push(data[i]); } that.errmsg=''; } else { that.errmsg='暂无更多数据'; } },'json'); } } })

    开始碰到个坑。请求到的数据我直接push到循环数组中,结果整个数组变成一个元素,后来想了想用循环把每一条数据分别push才解决这个问题

  • 相关阅读:
    第二次冲刺spring会议(第一次会议)
    团队项目(4.15站立会议)
    团队项目(4.14站立会议)
    VB中的GDI编程-1 设备环境DC
    合并多个表格数据的代码
    随机跳转页面之使用VBA公共变量
    快速找到Office应用程序安装路径
    CSS3学习笔记(3)-CSS3边框
    CSS3学习笔记(2)-CSS盒子模型
    测试一下js是否可用
  • 原文地址:https://www.cnblogs.com/liyinSakura/p/7047461.html
Copyright © 2011-2022 走看看