我做了一些实验,我发现 Meteor 会刷新<template> </template>块中的所有内容,只要其中一个值发生更改,例如:{{test}}...
<body>
    ...
  <div id="main-pane">
    {{> todos}}
  </div>
    ...
</body>
<template name="todos">
  {{test}}
  {{#if any_list_selected}}
    <div id="items-view">
        ...
        <ul id="item-list">
          {{#each todos}}
  ->{{testa}}
            {{> todo_item}}
          {{/each}}
        </ul>
        ...
    </div>
  {{/if}}
</template>
以及 .js 文件中的 setTimeout 来查找 和 的预期{{test}}变化{{testa}}:
Session.setDefault('test', 'aaa');
Template.todos.test = function () {
  return new Date().getTime() + Session.get('test');
};
setTimeout(function () { Session.set('test', 'bbb'); }, 2000);
Template.todos.testa = function () {
  return new Date().getTime(); //the timestamps will be refresh at the same time that test will do...
};
无论{{testa}}模板放在哪里,它显示的时间戳都会在我们每次执行时更新Session.get('test')。
我不知道这是否是一个有效的实验......所以我想知道这是否有效:所有模板都重新渲染?因为我认为反应式模板是别的东西......更漂亮......(?)