Meteor - onRendered不是一个函数

时间:2015-04-23 18:12:08

标签: meteor meteor-blaze

我有最新版本的Meteor ......

D:\lib>netstat -a

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:135            Firestorm:0            LISTENING
  TCP    0.0.0.0:443            Firestorm:0            LISTENING
  TCP    0.0.0.0:445            Firestorm:0            LISTENING
  TCP    0.0.0.0:1433           Firestorm:0            LISTENING
  TCP    0.0.0.0:3306           Firestorm:0            LISTENING
  TCP    0.0.0.0:3389           Firestorm:0            LISTENING
  TCP    0.0.0.0:5357           Firestorm:0            LISTENING
  TCP    0.0.0.0:8009           Firestorm:0            LISTENING
  TCP    0.0.0.0:8080           Firestorm:0            LISTENING
  TCP    0.0.0.0:8081           Firestorm:0            LISTENING
  TCP    0.0.0.0:8109           Firestorm:0            LISTENING
  TCP    0.0.0.0:10990          Firestorm:0            LISTENING
  TCP    0.0.0.0:47001          Firestorm:0            LISTENING
  TCP    0.0.0.0:49152          Firestorm:0            LISTENING
  TCP    0.0.0.0:49153          Firestorm:0            LISTENING
  TCP    0.0.0.0:49154          Firestorm:0            LISTENING
  TCP    0.0.0.0:49155          Firestorm:0            LISTENING
  TCP    0.0.0.0:49158          Firestorm:0            LISTENING
  TCP    0.0.0.0:49163          Firestorm:0            LISTENING
  TCP    0.0.0.0:50231          Firestorm:0            LISTENING
  TCP    127.0.0.1:1433         Firestorm:50240        ESTABLISHED
  TCP    127.0.0.1:1433         Firestorm:50241        ESTABLISHED
  TCP    127.0.0.1:1433         Firestorm:50242        ESTABLISHED
  TCP    127.0.0.1:1433         Firestorm:50243        ESTABLISHED
  TCP    127.0.0.1:1433         Firestorm:50244        ESTABLISHED
  TCP    127.0.0.1:1433         Firestorm:50245        ESTABLISHED
  TCP    127.0.0.1:1434         Firestorm:0            LISTENING
  TCP    127.0.0.1:3306         Firestorm:50221        ESTABLISHED
  TCP    127.0.0.1:3306         Firestorm:50237        ESTABLISHED
  TCP    127.0.0.1:3306         Firestorm:50238        ESTABLISHED
  TCP    127.0.0.1:3306         Firestorm:50239        ESTABLISHED
  TCP    127.0.0.1:8005         Firestorm:0            LISTENING
  TCP    127.0.0.1:8009         Firestorm:50432        ESTABLISHED
  TCP    127.0.0.1:8009         Firestorm:50460        ESTABLISHED
  TCP    127.0.0.1:8009         Firestorm:50461        ESTABLISHED
  TCP    127.0.0.1:8105         Firestorm:0            LISTENING
  TCP    127.0.0.1:8109         Firestorm:50252        ESTABLISHED
  TCP    127.0.0.1:8109         Firestorm:50257        ESTABLISHED
  TCP    127.0.0.1:8109         Firestorm:50258        ESTABLISHED
  TCP    127.0.0.1:8109         Firestorm:50259        ESTABLISHED
  TCP    127.0.0.1:8109         Firestorm:50260        ESTABLISHED
  TCP    127.0.0.1:8109         Firestorm:50261        ESTABLISHED
  TCP    127.0.0.1:50221        Firestorm:3306         ESTABLISHED
  TCP    127.0.0.1:50237        Firestorm:3306         ESTABLISHED
  TCP    127.0.0.1:50238        Firestorm:3306         ESTABLISHED
  TCP    127.0.0.1:50239        Firestorm:3306         ESTABLISHED
  TCP    127.0.0.1:50240        Firestorm:ms-sql-s     ESTABLISHED
  TCP    127.0.0.1:50241        Firestorm:ms-sql-s     ESTABLISHED
  TCP    127.0.0.1:50242        Firestorm:ms-sql-s     ESTABLISHED
  TCP    127.0.0.1:50243        Firestorm:ms-sql-s     ESTABLISHED
  TCP    127.0.0.1:50244        Firestorm:ms-sql-s     ESTABLISHED
  TCP    127.0.0.1:50245        Firestorm:ms-sql-s     ESTABLISHED
  TCP    127.0.0.1:50252        Firestorm:8109         ESTABLISHED
  TCP    127.0.0.1:50257        Firestorm:8109         ESTABLISHED
  TCP    127.0.0.1:50258        Firestorm:8109         ESTABLISHED
  TCP    127.0.0.1:50259        Firestorm:8109         ESTABLISHED
  TCP    127.0.0.1:50260        Firestorm:8109         ESTABLISHED
  TCP    127.0.0.1:50261        Firestorm:8109         ESTABLISHED
  TCP    127.0.0.1:50432        Firestorm:8009         ESTABLISHED
  TCP    127.0.0.1:50460        Firestorm:8009         ESTABLISHED
  TCP    127.0.0.1:50461        Firestorm:8009         ESTABLISHED
  TCP    172.18.4.325:139       Firestorm:0            LISTENING
  TCP    172.18.4.325:1433      192.168.4.78:55377     ESTABLISHED
  TCP    172.18.4.325:1433      192.168.4.78:55378     ESTABLISHED
  TCP    172.18.4.325:1433      192.168.4.78:55379     ESTABLISHED
  TCP    172.18.4.325:1433      192.168.4.78:56365     ESTABLISHED
  TCP    172.18.4.325:1433      192.168.4.78:56366     ESTABLISHED
  TCP    172.18.4.325:1433      192.168.4.78:56367     ESTABLISHED
  TCP    172.18.4.325:3389      192.168.4.78:51196     ESTABLISHED
  TCP    172.18.4.325:52756     198.135.8.228:1414     TIME_WAIT
  TCP    172.18.4.325:52760     198.135.8.228:1414     TIME_WAIT
  TCP    172.18.4.325:52767     Firestorm:50231        TIME_WAIT
  TCP    172.18.4.325:52771     198.135.8.228:1414     TIME_WAIT
  TCP    172.18.4.325:52775     198.135.8.228:1414     TIME_WAIT
  TCP    172.18.4.325:52776     172.18.5.220:1415      SYN_SENT
  TCP    [::]:135               Firestorm:0            LISTENING
  TCP    [::]:443               Firestorm:0            LISTENING
  TCP    [::]:445               Firestorm:0            LISTENING
  TCP    [::]:1433              Firestorm:0            LISTENING
  TCP    [::]:3306              Firestorm:0            LISTENING
  TCP    [::]:3389              Firestorm:0            LISTENING
  TCP    [::]:5357              Firestorm:0            LISTENING
  TCP    [::]:10990             Firestorm:0            LISTENING
  TCP    [::]:47001             Firestorm:0            LISTENING
  TCP    [::]:49152             Firestorm:0            LISTENING
  TCP    [::]:49153             Firestorm:0            LISTENING
  TCP    [::]:49154             Firestorm:0            LISTENING
  TCP    [::]:49155             Firestorm:0            LISTENING
  TCP    [::]:49158             Firestorm:0            LISTENING
  TCP    [::]:49163             Firestorm:0            LISTENING
  TCP    [::]:50231             Firestorm:0            LISTENING
  TCP    [::1]:1434             Firestorm:0            LISTENING

这是the documentation所说的......

meteor --version
Meteor 1.1.0.2

这是我的js代码......

Template.codeSample.onRendered(function () {
  hljs.highlightBlock(this.findAll('pre'));
});

这是我的模板......

if (Meteor.isClient) {
  Template.virtuebox.onRendered(function () {
    console.log("hi")
  });
}

这是方法列表...

enter image description here

这是错误......

<template name="virtuebox">     
      <div class="box">
        <span>{{text}}</span>
        <input type="number" value="0.5" step="0.1" min="0" max="1" name={{text}} />
      </div>
</template>

我做错了什么?

1 个答案:

答案 0 :(得分:1)

这很奇怪......我真的很想知道你是不是对你的系统不好看。

真的,新的

Template.foo(onRendered(function(){}));

机制是有意义的,因为它提供了多个回调而不是旧的

Template.foo.rendered = function(){};

只给了你一个 - 但这不会导致你的问题。

缺少Template.prototype的一些可见部分(即onCreated,onRendered,onDestroyed和_getCallbacks函数以及_callbacks对象)让我觉得你的系统上的packages / blaze / template.js已经被某种方式破坏了。

您可能会尝试查看旧的Template.foo.rendered是否有效,尽管_getCallbacks函数的代码内文档说明了

// Fire all callbacks added with the new API (Template.onRendered())
// as well as the old-style callback (e.g. Template.rendered) for
// backwards-compatibility.

我不知道这会更好;它不清楚你系统上的内容。

如果做不到这一点,我会尝试从您的系统中删除流星并重新安装它。如果你的系统中的流星源遭到攻击,重新安装就应该解决它。