如何使用Aurelia通过单击内部锚点链接保持在同一页面上? [英] How do I keep on the same page by clicking on internal anchor links, using Aurelia?

查看:81
本文介绍了如何使用Aurelia通过单击内部锚点链接保持在同一页面上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一个项目制作样式指南,目前我希望锚链接具有基本的单击行为,以便它们滚动到对应的ID.

I am working on a styleguide for a project and currently I would like to have a basic clicking behaviour on anchor links, so that they scroll to the correspondent id.

例如:

<a href="#section"></a>

向下滚动到:

<div id="section"></div>

在Aurelia中,默认行为是将链接视为路由.我无法使用内部链接,因为它会立即将我发送到外部页面.

In Aurelia, the default behaviour is to treat links as routes. I can't get the internal link to work, as it immediately sends me to an external page.

有人知道如何克服这个问题吗?谢谢!

Does someone know how to overcome this issue? Thanks!

推荐答案

您可以按照

You can disable the Aurelia router highjacking the link in several different ways, as per the documentation. One of the ways is to use one of these special attributes:

<a href="/some/link" download>Skip Hijacking</a>
<a href="/some/link" download="">Skip Hijacking</a>
<a href="/some/link" router-ignore>Skip Hijacking</a>
<a href="/some/link" router-ignore="">Skip Hijacking</a>
<a href="/some/link" data-router-ignore>Skip Hijacking</a>
<a href="/some/link" data-router-ignore="">Skip Hijacking</a>

这篇关于如何使用Aurelia通过单击内部锚点链接保持在同一页面上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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