對於第2點:
您可以使它像下面嗎? :
url的可變部分由'window.location.pathname'設置;
library urls;
import 'dart:html';
import 'package:route/client.dart';
final String _pathName = window.location.pathname;
final UrlPattern _base = new UrlPattern("${_pathName}");
final UrlPattern home = new UrlPattern("${_pathName}#home");
final UrlPattern page2 = new UrlPattern("${_pathName}#page2");
// useFragment: true is important! allow keep '#" un url
// allow to bookmark be valid when browser is closed and reopen.
final Router router = new Router(useFragment: true)
// simple hack to redirect/to /#home (home UrlPattern)
..addHandler(_base, (_) => window.location.hash = "#home");
main() {
router..addHandler(home, showHome)
..addHandler(page2, showPage2)
..listen();
}
void showHome(String path) {
query("body").children
..clear()
..add(new Element.html("<h1>Home</H1>"));
}
void showPage2(String path) {
query("body").children
..clear()
..add(new Element.html("<h1>Page2</H1>"));
}
1)從外觀上看,服務器端有一個'defaultStream',但是我沒有在客戶端看到你所提到的。也許提出一個錯誤? – 2013-05-06 19:09:26