簡體   English   中英

流星鐵路由器沒有加載模板

[英]Meteor Iron Router not loading template

我正在嘗試使用鐵路由器加載模板,並且沒有用於路由加載的模板。 單擊項目時,URL將更改,但當前頁面永遠不會更改。

Lib / router.js -

Router.configure({
  // we use the  appBody template to define the layout for the entire app
  layoutTemplate: 'appBody',

  // the appNotFound template is used for unknown routes and missing lists
  notFoundTemplate: 'appNotFound',

  // show the appLoading template whilst the subscriptions below load their data
  loadingTemplate: 'appLoading',

  // wait on the following subscriptions before rendering the page to ensure
  // the data it's expecting is present
  waitOn: function() {
    return [
      Meteor.subscribe('users'),
      Meteor.subscribe('roles')
    ];
  }
});

dataReadyHold = null;

if (Meteor.isClient) {
  // Show the loading screen on desktop
  Router.onBeforeAction('loading', {except: ['join', 'signin']});
  Router.onBeforeAction('dataNotFound', {except: ['join', 'signin']});

}

Router.map(function () {
  Router.route('home', {
    path: '/',
    onBeforeAction: function() {
      this.next();
    },
    action: function() {
      this.render('home');
    }
  });
  Router.route('adminPanel', {
    path: 'adminPanel',
    onBeforeAction: function() {
      this.next();
    },
    action: function() {
      console.log("hit admin");
      this.render('adminPanel');
    }
  });

});

這兩個鏈接:

            <li>
                <a href="/"><i class="fa fa-home"> Home</i></a>
            </li>
            <li>
                <a href="/adminPanel"><i class="fa fa-users"> Administration Panel</i></a>
            </li>

'home'模板非常基本:

<template name="home">
<h1>Welcome </h1>
<h2>Site in development</h2>
</template>

'adminPanel'模板:

<template name="adminPanel">
  <h1><i class="fa fa-users"> Administration Panel</i></h1>
    {{> addUserModal}}
    {{> tabular id="userTable" table=TabTables.Users class="table table-striped table-bordered table-condensed"}}
    {{> addRoleModal}}
    {{> tabular id="userTable" table=TabTables.Roles class="table table-striped table-bordered table-condensed" }}
    {{> autoformModals}}
</template>

如果它有幫助,這是文件結構:

.
├── client
│   ├── head.html
│   ├── routers
│   └── templates
│       ├── adminPanel.css
│       ├── adminPanel.html
│       ├── adminPanel.js
│       ├── app-not-found.html
│       ├── app-not-found.import.less
│       ├── appBody.html
│       ├── home.html
│       ├── loading.html
│       └── loading.import.less
├── lib
│   └── router.js
├── public
│   └── images
└── server
    └── publish.js

您不需要調用Router.map函數。 它沒有太大作用,你可以在這里看到。

如果您只是調用this.next()也可以省略onBeforeAction掛鈎。

但我也是,你的代碼看不出任何問題。 以下是您可以嘗試的一些事情:

  • 檢查您的subscriptions是否正常運行
  • 確保您的布局中的調用> yield
  • 檢查appLoading模板中的錯誤

暫無
暫無

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

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