试图在plunker中创建aurelia路由

时间:2018-05-02 19:07:50

标签: aurelia aurelia-router aurelia-framework

我正致力于在plunker中创建一个演示aurelia routing的网页。这是link。出于某种原因,我无法在页面中显示路线。我能够在我的本地环境中运行类似的代码。我认为这是必须以不同方式完成的东西。

以下是代码:

app.html

<template>
  <h1>Hello</h1>
  <div class="row col-lg-6 col-lg-offset-3">
    <div class="btn-group col-sm-offset-1" role="group" aria-label="...">
      <a repeat.for="row of router.navigation" class="${row.isActive ? 'active btn btn-primary' : 'btn btn-default'}" href.bind="row.href">
        ${row.title}
      </a>
    </div>
    <router-view></router-view>
  </div>
</template>

app.ts

import { Aurelia, PLATFORM } from "aurelia-framework";
import { Router, RouterConfiguration } from "aurelia-router";

export class App {
  router: Router;
  // Configure Routing
  configureRouter(config: RouterConfiguration, router: Router): void {
    console.log("Aurelia routing");
    config.title = "Aurelia Routing";
    // config.options.root = "/";
    config.map([
      {
        route: "",
        redirect: "home",
        settings: { icon: "home" }
      },
      {
        route: "home",
        moduleId: "./Home",
        nav: true,
        title: "Home",
        settings: { icon: "home" }
      },
      {
        route: "/support",
        moduleId: "./Support",
        nav: true,
        title: "Support Request",
        settings: { icon: "home" }
      }
    ]);
    this.router = router;
    console.log(router);
  }
  // console.log(this.router);
}

可以在plunker link中找到更多详细信息,例如自举等。

1 个答案:

答案 0 :(得分:2)

receive_espeak_events

中出现错误/错误
main.ts

应该是:

aurelia.use.basicConfiguration()

更改此内容,我看到了您在配置中输入的aurelia.use.standardConfiguration() 消息,但我收到了另一个错误,但路由现在可以正常工作。