Я пытаюсь загрузить шаблоны с помощью железного маршрутизатора и ни один из шаблонов для загрузки маршрутов. URL-адрес изменится, когда элементы будут нажаты, но текущая страница никогда не изменится.Meteor Iron Router не загружается шаблон
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>
'Главная' шаблон является очень простой:
<template name="home">
<h1>Welcome </h1>
<h2>Site in development</h2>
</template>
Шаблон 'админпанель:
<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
Можем ли мы см. сами шаблоны? Правильно ли они названы? Также вы можете использовать пути железных маршрутизаторов, например 'href =" {{pathFor 'home'}} "- рекомендуемый способ использования пути для маршрута. – cwahlfeldt
Ошибка в консоли? – Billybobbonnet
В консоли не отображается ошибка. При использовании 'href =" {{pathFor 'home'}} «мне все еще нужны функции в router.js? – Nighthawk