我现在正在与Meteor合作,并且我试图通过在数字变化时添加数字转换来使其看起来更"真实".我能看到的最好的第三方软件包是http://github.hubspot.com/odometer/.
我无法让程序包在Meteor中工作以更新项目上的注释编号.
我已经尝试将javascript放入客户端/兼容性中,根据流星文档:http://docs.meteor.com/#structuringyourapp,但没有快乐.
另一个问题可能是包使用CSS转换,这意味着围绕正在更新的数字重新呈现模板将阻止转换发生.为了尝试解决这个问题,我使用{{#isolate}}围绕数字,但这也不起作用.
有没有人对流星中的其他东西有什么其他想法?
我认为你应该尝试{{#constant}}而不是{{#isolate}}。另请注意,模板的“常量”部分将不再是反应性的,因此您必须手动更新它。假设你有一个模板
<template name="myTemplate">
{{#constant}}
<span class="odometer"></span>
{{/constant}}
</template>
Run Code Online (Sandbox Code Playgroud)
你需要做这样的事情:
Template.myTemplate.rendered = function () {
var node = this.find('.odometer');
Deps.autorun(function () {
node.innerHtml = MyCollection.find({}).count();
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
268 次 |
| 最近记录: |