HREF ="#"导致位置的地址改变,我们能避免呢? [英] href="#" causes location address to change, can we avoid it?
问题描述
我有一个数字,我处理特殊的逻辑,所以应该不会发生地址栏的地址变更标签。我有以下
I have a number of tabs that I handle special logic so no location bar address change should occur. I have the following
<a href="#">Home</a>
此行为与预期,即,它悬停在按下按钮时,但点击然后启动路由变化带给我的手鼠标指针。我希望能阻止这一切。
This behaves as expected, i.e. it gives me the hand mouse pointer when hovering over the buttons but clicking on then starts the route change. I want to be able to stop this.
我尝试只是删除的href
或设置的href =
,似乎有一些成功,但它给了意想不到的结果时,徘徊
I tried just remove the href
or setting href=""
, seemed to have some success but it gave unexpected results when hovering.
什么是最好的做法吗?我一定要删除的href?于是我就需要使用CSS徘徊时,给我的鼠标指针样式的标签?如果我离开的href =#
中的链接,然后这会导致路由的变化,这不是我所期待的。
What is the best practice here? Do I have to remove the href? So then I will need to style the tab using CSS to give me the mouse pointer when hovering? If I do leave the href="#"
in the link then this causes a change of routing which is not what I was looking for.
其实我处理我在 ngClick
登录为每个标签。这个逻辑不能改变路线。
I actually handle my login in a ngClick
for each tab. This logic must not change the route.
任何想法?
推荐答案
尝试这样做:
<a href="javascript:void(0);">Home</a>
这篇关于HREF =&QUOT;#&QUOT;导致位置的地址改变,我们能避免呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!