Weex踩坑实录

2018-05-11  本文已影响0人  LevyLin

1.新组件<recycle-list>无法与<loading>配合使用。目前遇到的情况主要是loading没法正常隐藏。

    <recycle-list class="gb-box" for="item in results">
        <cell-slot >
          <image class="i-gd" :src="item.url" resize="cover"/>
        </cell-slot>
        <loading class="loading" :display="loadinging?'show':'hide'" @loading="onloadMore">
          <text class="indicator-text">Loading ...</text>
          <loading-indicator class="indicator"></loading-indicator>
        </loading>
    </recycle-list>

方法如下:

methods: {
    loadData(index) {
      modal.toast({
        message: "loadData..." + index,
        duration: 2.0
      });
      stream.fetch(
        {
          method: "GET",
          type: "json",
          url: "http://gank.io/api/data/福利/10/" + index
        },
        res => {
          let data = res.data;
          this.loadinging = false;
          if (!data["error"]) {
            this.results.push(...data["results"]);
          }
        }
      );
    },
    onloadMore() {
      this.index++;
      this.loadinging = true;
      this.loadData(this.index);
    }
  }

在加载成功后,居然就是不隐藏<loading>,后来改成<list>就正常了
如下:

    <list class="gb-box">
        <cell v-for="item in results">
          <image class="i-gd" :src="item.url" resize="cover"/>
        </cell>
        <loading class="loading" :display="loadinging?'show':'hide'" @loading="onloadMore">
          <text class="indicator-text">Loading ...</text>
          <loading-indicator class="indicator"></loading-indicator>
        </loading>
    </list>
上一篇下一篇

猜你喜欢

热点阅读