根据Meteor的文档,在#isolate块内部更改内容不会导致父模板重新呈现,但对于以下示例,我遇到了不同的行为,其中'hello '和 'a' 重新呈现当我改变 '标题':流星:更改子模板而不重新渲染父模板
<head>
<title>testing</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
{{#isolate}}
{{> a}}
{{/isolate}}
{{#isolate}}
{{> b}}
{{/isolate}}
</template>
<template name='a'>
a: {{title}}
</template>
<template name='b'>
b: {{desc}}
</template>
这里是JavaScript
if (Meteor.isClient) {
Template.hello.rendered = function() {
console.log('hello')
};
Template.a.rendered = function() {
console.log('a')
};
Template.b.rendered = function() {
console.log('b')
};
Handlebars.registerHelper('title', function() {
return Session.get('title');
});
Handlebars.registerHelper('desc', function() {
return Session.get('desc');
});
}
难道我误解的东西吗?我在这里看到了一个类似但没有答案的问题: Meteor: Changing a subtemplate without changing parent template
请注意'{{#isolate}}'[不再](https://github.com/meteor/meteor/wiki/Using-Blaze#no-more-constant-isolate-or-preserve)[Spacebars]的一部分(https://github.com/meteor/meteor/blob/devel/packages/spacebars/README.md)。 –