简体   繁体   English

从外部深度链接到Ember应用

[英]Deeplink to Ember app from outside

How can I deeplink to my Ember app from outside ? 我该如何从外部深度链接到我的Ember应用程序? Say I want to deeplink to within my ember route (mainPage\\deepRoute) 说我想在余烬路线(mainPage \\ deepRoute)中进行深层链接

So when user clicks on the external link (not part of my Ember app), he is directly taken to mainPage\\deepRoute 因此,当用户单击外部链接(不是我的Ember应用程序的一部分)时,他将被直接带到mainPage \\ deepRoute

How will I code such a link ? 我将如何编码这样的链接?

I assume by default the Ember application template would be rendered, but I want to direct route to some other link/template ? 我假设默认情况下会渲染Ember应用程序模板,但我想将路由定向到其他链接/模板?

You can simply link inside to any route of your Ember.js app directly, however your webserver has to be configured with url redirect to the index.html . 您可以直接在内部直接链接到Ember.js应用程序的任何路由,但是必须使用重定向到index.html url配置您的Web服务器。

For example, if you use nginx as a webserver, you should have something like this in your nginx config file: 例如,如果您将nginx用作网络服务器,则您的nginx配置文件中应该包含以下内容:

location / {
  try_files $uri /index.html;
}

Option Two : if you cannot update the webserver, for example, you use GitHub pages, you have to use the #-ed url option. 选项二 :例如,如果您无法更新Web服务器,则使用GitHub页面,则必须使用#-ed url选项。 In this case, a url looks like this: example.com/#/posts/1/comments 在这种情况下,URL如下所示:example.com/#/posts/1/comments

More info here: http://guides.emberjs.com/v2.1.0/configuring-ember/specifying-url-type/ 此处提供更多信息: http : //guides.emberjs.com/v2.1.0/configuring-ember/specifying-url-type/

Make sure the server will load the single Ember html page for that url. 确保服务器将为该URL加载单个Ember html页面。 You can create a 'catchall' route in your web framework that aliases (not redirects to) your index.html view, - probably at the bottom of your server route definitions - or manually alias whichever specific route you are concerned with. 您可以在Web框架中创建一个“ catchall”路由,该索引可以为index.html视图(而不是重定向到该视图)添加别名(可能在服务器路由定义的底部),也可以手动为您关心的特定路由添加别名。

Then once Ember is loaded it will enter the route specified in the url and use any query params that were specified. 然后,在加载Ember之后,它将输入url中指定的路由,并使用指定的任何查询参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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