Aurelia路由器未定义
我正在尝试为Aurelia设置路由器配置。 该项目是用Aurelia路由器未定义,aurelia,Aurelia,我正在尝试为Aurelia设置路由器配置。 该项目是用aunew创建的,而aurun--watch用于运行Aurelia,效果很好 我的基本结构如下所示: Index.html src ---家 -------home.html ---app.ts ---app.html ---梅因酒店 我所有类的代码是: // main.ts: import {Aurelia} from 'aurelia-framework' import environment from './environmen
aunew
创建的,而aurun--watch
用于运行Aurelia,效果很好
我的基本结构如下所示:
Index.html
src
---家
-------home.html
---app.ts
---app.html
---梅因酒店
我所有类的代码是:
// main.ts:
import {Aurelia} from 'aurelia-framework'
import environment from './environment';
export function configure(aurelia: Aurelia) {
aurelia.use
.standardConfiguration()
.feature('resources');
if (environment.debug) {
aurelia.use.developmentLogging();
}
if (environment.testing) {
aurelia.use.plugin('aurelia-testing');
}
aurelia.start().then(() => aurelia.setRoot());
}
// index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app="main">
<script src="scripts/vendor-bundle.js" data-main="aurelia-bootstrapper"></script>
<script src="scripts/app-bundle.js" ></script>
<script src="./jquery/jquery-3.2.1.min.js"></script>
<script src="./bootstrap/js/bootstrap.js"></script>
</body>
</html>
//main.ts:
从“Aurelia框架”导入{Aurelia}
从“./environment”导入环境;
导出功能配置(aurelia:aurelia){
奥雷莉亚。用途
.standardConfiguration()
.特征(“资源”);
if(environment.debug){
aurelia.use.developmentLogging();
}
if(环境测试){
aurelia.use.plugin('aurelia-testing');
}
然后(()=>aurelia.setRoot());
}
//index.html
奥雷利亚
以下两类确实会产生问题:
// app.ts
import { Aurelia, PLATFORM } from 'aurelia-framework';
import { Router, RouterConfiguration } from 'aurelia-router';
export class App {
router: Router;
configureRouter(config: RouterConfiguration, router: Router) {
config.title = 'MyTitle';
config.map([{
route: [ '', 'home' ],
name: 'home',
moduleId: PLATFORM.moduleName('./home/home'),
nav: true,
title: 'Home'
}
]);
this.router = router;
}
}
// app.html
<template>
<require from="navmenu/navmenu.html"></require>
<require from="./bootstrap/css/bootstrap-grid.min.css"></require>
<div class="container">
<div class="row">
<div class="col-sm-12">
<navmenu router.bind="router"></navmenu>
<div class="col-sm-12" style="background-color:#9f0206; height:10px;">
</div>
</div>
</div>
<div class="row">
<div class="body-content container">
<div class="col-lg-12 page-host">
<router-view></router-view>
</div>
</div>
</div>
</div>
</template>
//app.ts
从“Aurelia框架”导入{Aurelia,PLATFORM};
从“aurelia路由器”导入{Router,RouterConfiguration};
导出类应用程序{
路由器:路由器;
配置路由器(配置:路由器配置,路由器:路由器){
config.title='MyTitle';
config.map([{
路线:[“家”],
姓名:'家',
moduleId:PLATFORM.moduleName('./home/home'),
导航:是的,
标题:“家”
}
]);
this.router=路由器;
}
}
//app.html
据我所知,
标签是路由器所必需的。删除此标记时,将呈现布局,但app.ts中指定的数据除外。
使用此行,浏览器会导致以下错误:
我做错了什么?路由器是否未注入或不可用?您是否没有
home/home.ts
model类?您必须有home.ts类