告诉Iron Router不要拦截链接 [英] Tell Iron Router not to intercept a link

查看:49
本文介绍了告诉Iron Router不要拦截链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将大量应用程序迁移到Iron Router.在客户端,所有未知路由都重定向到/404.另外,某些路由是从服务器端管理的,例如/static,它仅通过中间件显示静态页面.问题在于,Iron Router现在会拦截所有链接单击-因此,当我单击指向/static的链接时,将阻止该操作,浏览器不会显示该地址的服务器响应,而是将用户重定向到/404. /p>

如何防止此类行为?有没有办法告诉Iron Router不要截取某个链接?

解决方案

您可以使用css选择器告诉铁路由器应该链接到哪个链接:

IronLocation.configure({
    'linkSelector' : 'a[href], a:not([skipir])'
});

那么您可以拥有<a href=".." skipir>Skip this route</a>

I'm moving quite a large application to Iron Router. On the client side, all unknown routes are redirected to /404. In addition, some routes are managed from the server side - for example /static, that just displays a static page via middleware. The problem is that Iron Router now intercepts all link clicks - so when I click a link to /static, the action is prevented, browser does not display the server response for that address, and user is redirected to /404 instead.

How do I prevent such behavior? Is there a way to tell Iron Router not to intercept a certain link?

解决方案

You can tell iron router which links it should hook into with the css selector:

IronLocation.configure({
    'linkSelector' : 'a[href], a:not([skipir])'
});

Then you could have <a href=".." skipir>Skip this route</a>

这篇关于告诉Iron Router不要拦截链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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