myronliu347 / vue-carbon

此项目已停止维护,建议迁移到 https://github.com/museui/muse-ui/
861 stars 135 forks source link

完全按照文档来的,无限加载,无法触发loadMore方法 #10

Closed SidFeng closed 8 years ago

SidFeng commented 8 years ago
<content v-el:scroller>
     <!--加载下拉刷新数据-->
    <refresh-control @refresh="refresh" :trigger="$els.scroller" :refreshing="refreshing"></refresh-control>
    <!--渲染数据-->
    <list >
      <item-cell v-for="item in list" ripple>
        <item-content>
          <item-title-row>
            <item-title>{{item.examName}}</item-title>
            <item-title-after>{{item.examCode}}</item-title-after>
          </item-title-row>
          <item-sub-title>
            <span v-if="item.status=='已确认'" class="examine-tag" v-link="'examine/answer/'+item.id">{{item.status}}</span>
            <span v-if="item.status=='待确认'" class="examine-tag examine-tag-wait" v-link="'examine/answer/'+item.id">答案{{item.status}}</span>
            <span v-if="item.status=='未上传'" class="examine-tag examine-tag-none">{{item.status}}</span>
            <span v-if="item.status=='计算中'" class="examine-tag examine-tag-progress">{{item.status}}</span>
          </item-sub-title>
          <item-text>
            {{item.gradeName}} {{item.subjectName}} {{item.nickName}}
          </item-text>
        </item-content>
      </item-cell>
    </list>
    <infinite-scroll :trigger="$els.scroller" @load="loadMore" :loading="loading"></infinite-scroll>
  </content>```
myronliu347 commented 8 years ago

loadMore 里的实现给我看看

SidFeng commented 8 years ago

loadMore () { debugger this.loading = true setTimeout(() => { this.loading = false if (this.end < 100) { for (let i = this.end; i < this.end + 20; i++) { this.list.push(this.list); } } this.end += 20 }, 1000); },

myronliu347 commented 8 years ago

infiniteScroll,实在滚动到底部才加载(load事件),没有滚动事件是不会加载的

export default {
  data () {
    return {
      items: ['1', '2', '3', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20'],
      end: 20,
      loading: false
    }
  },
  methods: {
    loadMore () {
      this.loading = true
      setTimeout(() => {
        this.loading = false
        if (this.end < 100) {
          for (let i = this.end; i < this.end + 20; i++) {
            this.items.push(String(i + 1))
          }
        }
        this.end += 20
      }, 1000)
    }
  }
}
myronliu347 commented 8 years ago

请问,是否已经解决?

SidFeng commented 8 years ago

有滚动事件啊

myronliu347 commented 8 years ago

能将这个页面代码完整的贴出来看看么

myronliu347 commented 8 years ago

现在是滚动到底部,没有触发load事件么?

SidFeng commented 8 years ago

是的,不会到loadmore里面去

myronliu347 commented 8 years ago

这个ui库使用的是flexbox做布局, 每个页面的 顶部都要一个 page 的样式

 <div class="page">
 页面内容
</div>

如果你的版本是 0.4.0

 <div class="vc-page">
 页面内容
</div>
myronliu347 commented 8 years ago

你先改成这样再试试

SidFeng commented 8 years ago

还是不行

myronliu347 commented 8 years ago

我看到了你的代码上有两个地方指定了v-el:scroller

<list v-el:scroller >

把这个去掉

SidFeng commented 8 years ago
<list v-el:scroller >

上面是因为我在尝试是不是这个元素选择出错,我又写了这个。不过,现在解决了,这个问题解决方法就是

 <div class="page">
 页面内容
</div>