您当前的位置: 首页 >  cmmboy1990

Vant 2.0 下拉刷新,上拉加载

cmmboy1990 发布时间:2021-06-17 11:54:46 ,浏览量:4

Vant 2.0 下拉刷新,上拉加载

核心代码如下:



  
    

    
    
      

        
          
        

        

          
            {{ item.newsTitle }}


            {{ item.createTime }}
          

        
      

    

    


  




import {
  listNews
} from "@/api/business/news/news.js";

export default {
  name: 'Test',
  data() {

    return {
      isFixedHeight: true,

      refreshing: false,
      loading: false,
      finished: false,
      dataList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        newsTitle: undefined,
        newsType: undefined,
        status: undefined
      },
    };
  },


  methods: {
    getCoverImage(res) {
      return process.env.VUE_APP_BASE_API + res
    },
    onClickLeft() {
      //返回上一页
      this.$router.go(-1)
    },
    getList() {

      listNews(this.queryParams).then(response => {
        if (this.refreshing) {
          this.dataList = [];
          this.refreshing = false;
        }
        // 加载状态结束
        this.loading = false;
        this.dataList = this.dataList.concat(response.rows);//追加数据
        this.finished = !response.hasNext;
        this.queryParams.pageNum += 1;//页数+1
      });
    },
    onRefresh() {
      this.queryParams.pageNum = 1
      // 清空列表数据
      this.dataList=[]
      this.finished = false;
      // 重新加载数据
      // 将 loading 设置为 true,表示处于加载状态
      this.loading = true;
      this.getList();
    },
  },

  created() {
    // this.getList();
  }

}


.container{
  width: 100%;
  height: 100%;
}
.news-right {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}


关注
打赏
1688896170
查看更多评论

cmmboy1990

暂无认证

  • 4浏览

    0关注

    131博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.4511s