vue-infinite-loading icon indicating copy to clipboard operation
vue-infinite-loading copied to clipboard

用element的表格 ui 会出现一直触发加载

Open wYuanHpp opened this issue 8 years ago • 11 comments

Version

最新

Vue.js version

3.0.1

What is expected?

What is actually happening?

开头两次加载还正常,之后会变成无限触发加载,我看了一下原因,是应为触发加载后并且渲染完成后,滚动条没有像预期的那样向上跳一段,而是直接顶到底,致使加载组件一直出现在窗口上,这样导致组件不停触发事件,这个有解决办法么?

How to reproduce this problem?

wYuanHpp avatar Feb 06 '18 10:02 wYuanHpp

如果 direction 是 top,需要手动处理 scrollTop 的变更:

PeachScript avatar Feb 06 '18 13:02 PeachScript

不是的 ,我是设成 bottom 的 ,但是出现的情况确实是设为 top 时出现的问题

wYuanHpp avatar Feb 09 '18 03:02 wYuanHpp

请提供一个重现问题的 live demo

PeachScript avatar Feb 09 '18 04:02 PeachScript

@PeachScript 个人也遇到类似的问题,具体场景是滚动条在body元素下, 建议你提供个独立的页面DEMO。

zhangbg avatar Feb 11 '18 09:02 zhangbg

加载组件versoin: ^2.3.1 InfiniteLoading 都是默认配置 我这边也有这样的情况: 1.迅速滑动到底部,加载组件会不挺触发infinite事件. 2.滚动条滑动到底部,此时重新刷新页面(滚动条一直存在底部)会一直触发infinite事件加载.

lyyGov123 avatar May 09 '18 14:05 lyyGov123

同样的问题,elementUI,默认配置,停留在list底部的时候,真的成了infinite loading,一直重复触发,卡死浏览器。

<template>
  <div v-loading="loading" element-loading-text="加载中...">
    <el-carousel :interval="5000" arrow="never">
      <el-carousel-item v-for="top_story in top_stories" :key="top_story.id">
        <h3>{{ top_story.title }}</h3>
        <img :src="top_story.image" @click="goStory(top_story.id)">
      </el-carousel-item>
    </el-carousel>

    <div class="list">
      <el-card class="box-card" v-for="story in stories" :key="story.id">
        <div class="text item" @click="goStory(story.id)">
          <img class="thumb image" :src="story.images[0]">
          <p>{{ story.title }}</p>
        </div>
      </el-card>
    </div>
    <infinite-loading @infinite="loadMore"></infinite-loading>
  </div>
</template>
import Api from './../api/index'
import InfiniteLoading from 'vue-infinite-loading'

export default {
  name: 'Home',
  components: {InfiniteLoading},
  mounted () {
      this.loading = true
    this.getList(0)
  data () {
    return {
      loading: true,
      top_stories: [],
      stories: []
    }
  },
  methods: {
    getList (offset) {
      var vue = this
      Api.getHomeList().then(function (res) {
        vue.top_stories = res.data.top_stories
        if (offset) {
          vue.stories.push(res.data.stories)
        } else {
          vue.stories = res.data.stories
        }
        vue.loading = false
      })
    },
    goStory (id) {
      this.$router.push({
        path: 'story',
        query: {
          id: id
        }
      })
    },
      loadMore ($state) {
        setTimeout(() => {
            console.log('loading...')
            $state.loaded()
        }, 2000)
      }
  }
}

2018-07-27 18_46_21

aiddroid avatar Jul 27 '18 10:07 aiddroid

@aiddroid 你的 loadMore 方法中没有对列表数据做追加,致使滚动条长度没发生变化,插件会认为容器内没有填充足够的数据,『一直重复触发』正是预期结果。

PeachScript avatar Aug 01 '18 06:08 PeachScript

这里是配合 ElementUI 卡片组件的 live demo:http://jsfiddle.net/h0Lt3b9s/ 。

如果各位在使用的时候仍然遇到问题,请 fork 此 demo 进行重现并贴出地址,以便分析问题产生的原因。

PeachScript avatar Aug 01 '18 07:08 PeachScript

https://jsfiddle.net/a7x5zdr7/19/ @PeachScript 您好,请问这个demo是什么问题呢?我发现删除css里的任一行,loading组件能够正常运行。

div { width: 49%; box-sizing: border-box; padding: 0 20px; }

Dragon-Rider avatar Aug 28 '18 12:08 Dragon-Rider

我遇到同样的问题

q640202047 avatar Sep 30 '18 08:09 q640202047

各位,关于如何与 Element UI 的表格组件一起使用,新版文档中已经已经给出了使用示例,以作参考。

此 issue 先行关闭,如果在使用过程中遇到问题,请继续在此进行讨论;如果遇到的是其他问题,请另开 issue 进行讨论。

PeachScript avatar Oct 26 '18 01:10 PeachScript