[英]Basic Router not working in Aurelia
Everything I have tried to do has given me the erorr in the Console. 我尝试做的所有事情都给了我控制台中的错误。 "ERROR [app-router] Error: Route not found: /(…)error"
“错误[应用程序路由器]错误:找不到路由:/(...)错误”
I don't understand what I could be doing incorrectly. 我不明白我可能做错了什么。
My folder paths are: 我的文件夹路径是:
--wwwroot
|_ src
|_app.html + app.js
|_home.html + home.js
|_mypage.html + mypage.js
My app.html page 我的app.html页面
<template>
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-lg-2">
<nav class="navbar navbar-default navbar-fixed-side">
<ul class="nav navbar-nav">
<li repeat.for="row of router.navigation" class="${row.isActive ? 'active' : ''}">
<a href.bind="row.href">${row.title}</a>
</li>
</ul>
</nav>
</div>
<div class="col-sm-9 col-lg-10">
<div class="row">
<h1>${message}</h1>
</div>
</div>
</div>
</div>
<div class="page-host">
<!-- Route mount point -->
<router-view></router-view>
</div>
</template>
My app.js file is 我的app.js文件是
export class App {
message = "Hello Pathways";
configureRouter(config, router) {
config.title = 'Scotch IG';
// Use map to set array of possible routes
config.map([
{ route: ['','home'], name: 'home', moduleId: './home', nav: true, title:'Home' },
{ route: 'mypage', name: 'mypage', moduleId: './mypage', nav: true, title:'MyPage' }
]);
// Create a binding to the router object
this.router = router;
}
}
I've tried throwing src/
in front of everything to try different folder structures. 我尝试将
src/
放在所有内容的前面,以尝试使用不同的文件夹结构。 But I'm starting to think something is wrong with the install. 但是我开始认为安装有问题。
My config.js under paths is "*": "src/*.js"
我在路径下的config.js是
"*": "src/*.js"
Give path in config.js as below 在config.js中给出路径,如下所示
paths: {
"*": "src/*",
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
This will take care. 这会照顾的。 If you any folder inside src, then give moduleId: foldername/Home .
如果您在src内有任何文件夹,请提供moduleId:foldername / Home 。
And one more point if you are using main.js file then check with setRoot to app file like 还有一点,如果您使用的是main.js文件,请使用setRoot检查应用程序文件,例如
aurelia.start().then(a => a.setRoot('app'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.