【问题标题】:Template keeps redrawing, despite no change to the underlying data尽管基础数据没有变化,模板仍会不断重绘
【发布时间】:2012-06-30 20:49:27
【问题描述】:

谁能告诉我为什么这个例子中渲染的 Live HTML 一直在清除然后在无限循环中重绘?此示例代码使我笔记本电脑上的 CPU 最大化。

环境:

  • 流星 0.3.7
  • Mac OS Lion
  • 在 Safari 5.1.7、Chrome Canary 22.0.1189、Chrome 21.0.1180、Firefox 11.0 和 13.0 中测试

初始项目创建:

meteor create test
cd test
meteor add coffeescript
mv test.js test.coffee
meteor

test.coffee:

Records = new Meteor.Collection("records")

if Meteor.is_client
    Template.table.records = ->
        Records.find()
    Template.table.rowCount = ->
        Records.find().count()

if Meteor.is_server
    Meteor.startup ->
        if Records.find().count() is 0
            for i in [1..1000]
                Records.insert({some:"test", data: "just", to: "check"})

test.html:

<head>
  <title>test</title>
</head>

<body>
    {{> table}}
</body>

<template name="table">
    <table>
        <caption>{{rowCount}}</caption>
        {{#each records}}
        <tr>
            <td>{{some}}</td>
            <td>{{data}}</td>
            <td>{{to}}</td>
        </tr>
        {{/each}}
  </table>  
</template>

【问题讨论】:

  • 我用不同的数据集大小运行了相同的示例代码:重绘问题似乎出现在大小超过 800 条记录的集合中......
  • 我已将其移至 Meteor 问题跟踪器。 github.com/meteor/meteor/issues/207
  • 是的,我注意到了,谢谢史蒂夫

标签: meteor


【解决方案1】:

尝试升级 Meteor。我刚刚在当前的 master 中尝试了这个确切的示例代码(在编写 0.5.2 时)。我在所有 Chrome、Firefox 和 Safari 中都打开了该页面,并且我的 CPU 使用率很低。

【讨论】:

    猜你喜欢
    • 2022-01-07
    • 1970-01-01
    • 2012-04-13
    • 2017-10-04
    • 1970-01-01
    • 2018-04-02
    • 1970-01-01
    • 1970-01-01
    • 2011-10-25
    相关资源
    最近更新 更多