标签:接下来 client 自己 结果 body .com javascrip called 调用
Meteor.setTimeout(function(){
console.log("Timeout called after three seconds..."); }, 3000);

meteorApp/client/app.html
<head>
<title>meteorApp</title>
</head>
<body>
<div>
{{> myTemplate}}
</div>
</body>
<template name = "myTemplate">
<button>CLEAR</button>
</template>
meteorApp/client/app.js
if (Meteor.isClient) {
var counter = 0;
var myInterval = Meteor.setInterval(function(){
counter ++
console.log("Interval called " + counter + " times...");
}, 3000);
Template.myTemplate.events({
‘click button‘: function(){
Meteor.clearInterval(myInterval);
console.log(‘Interval cleared...‘)
}
});
}
控制台将每三秒钟记录更新计数器- counter 变量。我们可以通过点击 CLEAR 按钮清除。这将调用 clearInterval 方法。
标签:接下来 client 自己 结果 body .com javascrip called 调用
原文地址:http://www.cnblogs.com/h2zZhou/p/7390002.html