简体   繁体   English

流星未捕获TypeError:无法读取未定义的属性“ push”

[英]Meteor Uncaught TypeError: Cannot read property 'push' of undefined

I'm getting 2 errors with my meteor app. 我的流星应用程序出现2个错误。 These are the errors below. 这些是下面的错误。 I'm using accounts-ui-bootstrap-3 and I'm trying to display my header template inside layout.html . 我正在使用accounts-ui-bootstrap-3,并试图在layout.html显示标题模板。

Here are my 2 errors with some code. 这是我的一些代码错误。

Uncaught TypeError: Cannot read property 'push' of undefined

Uncaught Error: There are multiple templates named 'layout'. Each template needs a unique name.

^^Even though I only have one template named layout. ^^即使我只有一个名为layout的模板。

Code: 码:

layout.html 的layout.html

 <template name="layout">
   <div class="container">
     {{>header}}
     <div id="main" class="row-fluid">
     {{>yield}}
     </div>
   </div>
 </template>

header.html 了header.html

<template name="header">
   <header class="navbar">
     <div class="navbar-inner">
       <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
       <span class="icon-bar"></span>
       <span class="icon-bar"></span>
       <span class="icon-bar"></span>
       </a>
       <a class="brand" href="{{pathFor 'postsList'}}">Test</a>
       <div class="nav-collapse collapse">
         <ul class="nav pull-right">
           <li>{{> loginButtons}}</li>
         </ul>
       </div>
    </div>
  </header>
</template>

Why isn't it displaying the loginbuttons? 为什么不显示登录按钮?

Router.js Router.js

Router.configure({
 layoutTemplate: 'layout',
 loadingTemplate: 'loading',
 waitOn: function() { return Meteor.subscribe('posts'); }
});
Router.map(function() {
 this.route('postsList', {path: '/'});

 this.route('postPage', {
    path: '/posts/:_id',
    data: function() { return Posts.findOne(this.params._id); }
 });
});

Do you use mrt:accounts-ui-bootstrap-3 or ian:accounts-ui-bootstrap-3? 您是否使用mrt:accounts-ui-bootstrap-3或ian:accounts-ui-bootstrap-3? if you use mrt:accounts-ui-bootstrap-3, it won't work because not supported anymore. 如果您使用mrt:accounts-ui-bootstrap-3,它将不再起作用,因为不再受支持。 Use ian:accounts-ui-bootstrap-3 instead. 请改用ian:accounts-ui-bootstrap-3。

You can omit the li element for the login buttons. 您可以省略登录按钮的li元素。 Change your header inclusion to look like this {{> header}} , notice the little caret. 将您的标头包含项更改为以下{{> header}} ,请注意小插入符号。

EDIT: 编辑:

Instead of using a Router.map try using Router.route like this: 代替使用Router.map尝试使用Router.route像这样:

Router.route('/', {
  name: 'postsList' 
});

Router.route({'/posts/:_id',
  name: 'postPage',
  data: function() {
    return Posts.findOne(this.params._id);
  }
});

暂无
暂无

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

相关问题 流星+反应“未捕获的TypeError:无法读取未定义的属性&#39;data&#39;” - meteor + react “Uncaught TypeError: Cannot read property 'data' of undefined” 流星未捕获TypeError:无法读取未定义的属性“ helpers” - Meteor Uncaught TypeError: Cannot read property 'helpers' of undefined 流星:未捕获TypeError:无法读取未定义的属性&#39;事件&#39; - Meteor: Uncaught TypeError: Cannot read property 'events' of undefined 加载FullCalendar&gt; Uncaught TypeError:无法读取未定义的属性&#39;push&#39; - FullCalendar on loading > Uncaught TypeError: Cannot read property 'push' of undefined 偶尔收到“未捕获的TypeError:无法读取未定义的属性&#39;push&#39;” - Getting “Uncaught TypeError: Cannot read property 'push' of undefined” sporadically 未捕获的类型错误:无法读取 Vuejs 中未定义的属性“推送” - Uncaught TypeError: Cannot read property 'push' of undefined in Vuejs 捕获TypeError:无法读取未定义的属性“ push” - Getting Uncaught TypeError: Cannot read property 'push' of undefined 数组:未捕获的类型错误:无法读取未定义的属性“推送” - Array: Uncaught TypeError: Cannot read property 'push' of undefined Javascript Uncaught TypeError:无法读取未定义的属性“推送” - Javascript Uncaught TypeError: Cannot read property 'push' of undefined 变量问题:未捕获的TypeError:无法读取未定义的属性“推” - variable problem: Uncaught TypeError: Cannot read property 'push' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM