我想通过模板传递数据,但是我不确定,我在客户模板中有两个变量,当用户单击时,我想将这两个变量传递给下一个模板customerchathistory,例如
Template.customer.events({
async 'click .list-chat'(event,template) {
const Rid = event.currentTarget.id;
const Rtoken = event.currentTarget.token;
}
})
在这里,我在customer.html中传递了像这样的那些var
{{>cutomerChatHistory clickRid= Rid clickRtoken = Rtoken }}
现在,当我在customerChatHistory.js中获取这两个变量时,我将变得未定义
Template.customerChatHistory.onCreated(function() {
const currentData = Template.currentData();
console.log(currentData.clickRid , currentData.clickRtoken) //giving undefined here
})
Rid
和Rtoken
变量,以便它们在Blaze html模板中可用:Template.customer.events({
async 'click .list-chat'(event,template) {
template.Rid.set(event.currentTarget.id);
template.Rtoken.set(event.currentTarget.token);
}
})
Template.customer.helpers({
Rid: function(){
return Template.instance().Rid.get();
}
Rtoken: function(){
return Template.instance().Rtoken.get();
}
})
Template.customer.onCreated({
this.Rid = new ReactiveVar(null)
this.Rtoken = new ReactiveVar(null)
})