繁体   English   中英

流星模板助手反应性不一致

[英]Meteor Template Helper Reactivity inconsistency

我有一个模板助手,用于显示带有反应式var schoolFindQuery的学校

    Template.schoolCompareCenterList.helpers({
  schools(){
    console.log("schoolFindQuery is :" + schoolFindQuery);
      let school =  Schools.find(JSON.parse(schoolFindQuery), {limit : 20});
      console.log("school count is : " + school.count());

        return school;
}
})

并且schoolFindQuery反应变量随按钮单击而变化,随按钮单击而被更新,并且ui也相应地变化。 奇怪的是,当订阅返回数据时没有问题,但是只要订阅返回任何数据,此后辅助程序代码就不会随着订阅更改而重新运行(即使我可以看到流星玩具的订阅),并且ui不显示任何数据。 我的订阅代码如下,

this.autorun(function() {


if(subscription)
  subscription.stop()


//This reactive variables set by buttons and by the ghelp of reactivty subscription rerun
    query = "{"
    if(_sTy__.get() != 0 && _sTy__ != null)
      query += "\"schoolType.schoolT\" : \"" +  _sTy__.get()+ "\","
    if (_sTy2__.get() != 0 && _sTy2__ != null)
      query += "\"schoolType.schoolTT\" : \""+  _sTy2__.get() +"\","
    if(regexSchoolName.get() != 0 && regexSchoolName.get() != null )
      query += "\"schoolName\" : {\"$regex\": \".*" + regexSchoolName.get() + ".*\", \"$options\": \"i\"},"

    query += "\"haveSchoolDetailInfo\" : true}"

    subscription = Meteor.subscribe("schoolCompare.infinite.publish", query,  20, 0);
    schoolFindQuery = query;})

提前致谢。

我建议您看一下本教程,其中介绍了会话变量,反应式字典和反应式变量: https : //blog.meteor.com/the-meteor-chef-reactive-dict-reactive-vars-and-session-variables-971584515a27 #.undr5c1f0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM