如何制作链接,导致他们自己,在整个项目中无法点击? Laravel 8

How to make links, leading to themselves, unclickable in the whole project? Laravel 8

任务:没有link应该导致它自己。

我做了什么:

view.blade.php:

<a href="{{route('namedRoute')}}
@if(route('namedRoute') == Request::url())
        class="disabled"
@endif
>Some link</a>

style.css:

a.disabled {
    cursor: not-allowed;
    text-decoration: none;
    pointer-events: none;
}

但这不是全球性的。可以有很多 link,并且对每个 link 手动执行 — 这不是正确的方法。也许,可以在中间件中以某种方式做?

如果必须将这些链接引向它们自己,您也许可以:

  1. 为此使用 <a href="#">(但您必须更改具有该 href 值的每个模板)
<div>
  <a href="#"></a>
</div>

也许,您可以使用 javascript:void(),这是一种替代“#”的方法

  1. 使用Javascript,为网络中的每个<a>元素添加一个事件侦听器,并将href设置为window.location.href(这将改变动态)

  2. 使用 javascript 禁用所有 href。