0
私のアプリケーションでAureliaのルーティングメカニズムを使用する際に問題があります。私のアプリは現在3ページで構成されています。 App(メインファイル)、ようこそとフォームページ。私はAuth0を使ってソーシャル・ログインを実装することができました。私の考えは、誰かがウェルカムページからログインし、フォームページにリダイレクトされたときです。私は試して、ルーターをaurelia-routerからインポートしてみましたが、常に未定義です。私はまだこの素晴らしいフレームワークのハングアップを取得していると私は大幅に誰かが私が間違って行った私を表示していただければ感謝します。ルータオブジェクトは常に未定義の状態です
ありがとうございます。コードは以下の通りです:
// app.js:
import {inject} from 'aurelia-framework';
import {Router} from 'aurelia-router';
@inject(Router)
export class App {
constructor(router) {
this.router = router;
this.router.configure(config => {
config.title = 'My App';
config.map([
{route: ['', 'welcome'], name: 'welcome', moduleId: 'welcome', nav: true, title: 'Welcome'},
{route: ['form', 'form'], name: 'form', moduleId: 'form', nav: false, title: 'Provide your Details'}
]);
});
console.log(this.router) // this properly displays the object in the console
}
}
//welcome.js:
import {inject} from 'aurelia-framework';
import {HttpClient} from 'aurelia-fetch-client';
import {Router} from 'aurelia-router';
@inject(HttpClient)
@inject(Router)
export class Welcome {
heading = 'Welcome to my App!';
lock = new Auth0Lock('xxxxxxxxxx', 'xxxxxxxxxx');
isAuthenticated = false;
constructor(http, router) {
this.http = http;
this.router = router;
console.log(router) // Shows undefined
}
login() {
// In welcome.html there is a button that succcessfully returns a successful facebook login. This function should navigate the user to the home page using:
this.router.navigate('form');
// But this says navigate property is not defined
}
}
私はかなりうまく説明しました。助けてくれてありがとう!