我一直在努力为我的 loadingTemplate 设置 3 秒超时。
使用下面的代码 loadingTemplate 被渲染,但它确实在经过 3 秒后重定向到 layoutTemplate,正如我所料。
请在下面找到我的代码和评论问题。
我也将此版本部署到http://ns1-timeout.meteor.com/
我很感激任何帮助。
Router.configure({
layoutTemplate: 'applayout',
loadingTemplate: 'loading',
waitOn: function () {
var isTimePassed = false;
var clock = 3;
var timeLeft = function() {
if (clock > 0) {
clock--;
Session.set("time", clock);
console.log(clock);
} else {
console.log("That's All Folks");
//return true
isTimePassed = true;
Meteor.clearInterval(interval);
console.log('is Time passed: '+ isTimePassed);
return isTimePassed; // seems it is being ignored
}
};
var interval = Meteor.setInterval(timeLeft, 1000);
return {
ready: function () {
console.log('return ready: ' + isTimePassed);
return isTimePassed; // keeps the loading page and does not redirect to applayout if changed to false, loadingTemplate is not loaded and
}
}
}
});