json - 在 polymer 中延迟加载巨大的 json 数据

标签 json polymer lazy-loading

我有一个包含大量数据的 JSON 文件,导致 HTML 页面在对其进行迭代时变得无响应。

我正在使用 Polymer 并迭代模板内的 JSON 数据。

有没有一种方法可以使用延迟加载进行迭代,这样我就不必同时加载所有数据?

下面是我的元素的 HTML 文件。

<polymer-element name="flash-card">
  <template id="k">
    <style>
      flip-card {
        width: 200px;
        height: 200px;
      }
    </style>
    <core-ajax id='ajaxCard'
      url='../api/gre_questions.json'
      on-core-response="{{onResponse}}"
      handleAs='json'></core-ajax>

    <div horizontal layout wrap style="width: 100%">
      <template repeat="{{words in json}}">

        <flip-card axis="y" class="flip-card">

          <front style="background:#232343">
            <div style="overflow:hidden">{{words.word}}</div>
          </front>
          <back>
            <div style="overflow:hidden">
              {{words.meaning}}
            </div>
          </back>
        </flip-card>
      </template>
    </div>
  </template>
  <script>
    Polymer("flash-card",{
      json: null,
      ready: function () {
        this.$.ajaxCard.go();
      },
      onResponse: function (e, detail, sender) {
        this.json = detail.response;
      }
    });
  </script>
</polymer-element>

最佳答案

<core-ajax id='ajaxCard' url='../api/gre_questions.json' on-core-response="{{onResponse}}" handleAs='json' ></core-ajax>
<core-list data="{{json}}" style="width:100%; height: 100%">
  <template>
    <div >
      <button></button>
      <core-collapse>
        <div class="collapse-content">
          {{model.word}} : {{model.meaning}}
        </div>
      </core-collapse>
    </div>
  </template>
</core-list>

关于json - 在 polymer 中延迟加载巨大的 json 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31532672/

相关文章:

javascript - Google map 库的延迟加载

angular - 为什么延迟加载模块必须导入 commonModule? Angular 2

json - 为什么我不能将 Map[String,Any] 序列化为 JSON?

java - JSON 上的 StringBuffer 替换

javascript - 在 Angular 组件中共享大的 json 数据是好是坏?

javascript - 在没有jquery的情况下单击Polymer js展开div

polymer - 无法理解 Polymer 2.0 自定义元素属性?

用于社交网络应用程序的来自服务器的 Android 画廊图像

json - 无法在 React 应用程序中访问来自 Express 服务器的响应数据

javascript - polymer 复位性能