之間有什麼區別:將數據添加到模板中不使用輔助功能
Session.set("sessionclickcount",1);
Template.hello.clickcount = Session.get("sessionclickcount");
和
Session.set("sessionclickcount",1);
Template.hello.clickcount = function()
{
return Session.get("sessionclickcount");
};
我嘗試使用下面的代碼更新會話變量以後更新的模板數據:
Template.hello.events({
'click input' : function() {
Session.set("sessionclickcount",
Session.get("sessionclickcount")+1);
}
});
第一種方法失敗,html不會更改。第二個成功。爲什麼?謝謝!
當OP說「第一種方法失敗......」他的意思是,「價值不變」,而不是「沒有顯示任何東西」。在這種情況下,值「1」將始終顯示。 – alanning
更改了它,謝謝。 – Akshat