Dart 聚合物布线 [英] Dart Polymer Routing

查看:34
本文介绍了Dart 聚合物布线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Dart 和 Polymer 的单页应用程序.我正在尝试使用 route_hierarchical

I have a single page app using Dart and Polymer. I'm trying to add a route to another page with route_hierarchical

到目前为止我所尝试的是像这样配置路由器:

What I've tried so far was configuring the router like this:

router = new Router()
router.root
  ..addRoute(name: 'games', path: '/games')
  ..addRoute(name: 'login', path: '/login')
  ..addRoute(name: 'home', defaultRoute: true, path: '/');
router.listen();

我发现我可以使用

new Router(useFragment: ...);

启用或不启用 URL 中的 hashbang.问题是当我不使用 hashbangs 时,我无法直接使用 URL 访问页面.(意味着当我点击按钮等时应用程序会路由我).有没有办法在没有 hashbangs 的情况下拥有可共享的 URL?我见过 AngularJs 使用类似

to enable the hashbangs in the URLs or not. The problem is that when I don't use hashbangs, I can't access a page using the URL directly. (meaning the app routes me when I click on buttons and such). Is there a way of having sharable URLS with no hashbangs? I've seen AngularJs using something like

$locationProvider.html5Mode(true)

要删除 hashbangs 并仍然具有可共享的 URL...我不知道我是否真的应该打扰没有 hashbangs 的 URL.我已经读到让它们给我带来 SEO 的麻烦,对吗?

to remove the hashbangs and still have sharable URLs... I don't know if I really should bother having URLs without hashbangs though. I've read having them is going to give me trouble with SEO, is that right?

我现在只使用 Polymer 和 route_hierarchical,不想只为了路由而使用 angular.dart.

I'm only using Polymer and route_hierarchical right now, and didn't want to go for angular.dart just for routing.

推荐答案

当你想使用没有片段的 URL 时,你也需要在服务器端使用路由器.

You need to use a router on the server side too when you want to use URLs without fragments.

另见

这篇关于Dart 聚合物布线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆