我在我的应用程序中添加了 Iron-router 来处理主页、关于页面和应用程序主页(即地图)之间的路由
在使用陨石添加 Iron-router 后,我编写了一个 router.js 文件并将其放在我的 /client 文件夹中,但是我收到一条错误消息,显示“未捕获的 ReferenceError:路由器未定义”
我用chrome devtools检查了错误,它指向了我在下面添加的router.js开头的“Router.configure(...”
Router.configure({
layoutTemplate: 'layout',
loadingTemplate: 'loading'
});
Router.map( function () {
//the about route
this.route('about', {
path: '/about',
template: 'about',
action: function () {
console.log('now routing the about template');
}
});
this.route('home', {
path: '/',
template: 'home',
action: function () {
console.log('now routing the home template');
}
});
//the map route
this.route('map', {
path: '/map',
template: 'map',
action: function () {
console.log('now routing the map template');
}
});
});
有谁知道为什么我收到路由器未定义的错误?