以下使用Chrome Logging API。如果在多个模板中使用了该语法,它将以图形方式将来自不同模板的控制台日志组织到分层树中。.group()
您还可以查看如何检查当前数据上下文以及如何对数据进行字符串化。
Template.landingPage.getId = function(){
// 使用组块来说明功能范围
console.group('coolFunction');
// 检查着陆页正在使用的当前数据对象
console.log(this);
// 检查本地范围的数据对象的特定字段
console.log(JSON.stringify(this._id);
// 关闭功能范围
console.groupEnd();
return this._id;
}