簡體   English   中英

如何在Meteor模板中共享變量?

[英]How can I share a variable within a Meteor template?

假設我有一個click事件,該事件調用服務器方法來查詢並返回存儲在變量a的產品代碼。 然后,我想在另一個click事件中使用變量a 有辦法嗎? 如果我只是用a在其他點擊事件,我得到一個不確定的消息。

會話非常有效。

Meteor.call("someServerMethod", anArgument, function(err, res){
  if !(err) {
    Session.set("variableName", res);
  }
});

然后,您可以使用:

Session.get("variableName");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM