简体   繁体   中英

trying to create aurelia routing in plunker

I am working on creating a page in plunker to demo aurelia routing . Here is the link . For some reason, I am unable to show the route in the page. I am able to run similar code in my local environment just fine. I think it is something in plunker that has to be done differently.

Here is the code:

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);
}

Further details, such as bootstrapping, etc can be found in plunker link .

There's a typo/error in your main.ts :

aurelia.use.basicConfiguration()

Should be:

aurelia.use.standardConfiguration()

Changing this, I saw the console.log messages you put in the configuration, but I got another error, but the routing works now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM