最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to get current route name in blade file laravel 5.6 - Stack Overflow

programmeradmin4浏览0评论

I want to reload my current page with onclick function, for this how to get my current route name in blade file.

This is my code:

<li class="dropdown user user-menu" onclick="window.location='{{ Route::current() }}'" style="cursor: pointer;">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown">
    <i class="livicon" data-name="refresh" data-loop="true" data-color="#42aaca" 
        data-hovercolor="#42aaca" data-size="28"></i>
  </a>
</li>

What is the best way to get the current route?

I want to use it on function onclick.

I want to reload my current page with onclick function, for this how to get my current route name in blade file.

This is my code:

<li class="dropdown user user-menu" onclick="window.location='{{ Route::current() }}'" style="cursor: pointer;">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown">
    <i class="livicon" data-name="refresh" data-loop="true" data-color="#42aaca" 
        data-hovercolor="#42aaca" data-size="28"></i>
  </a>
</li>

What is the best way to get the current route?

I want to use it on function onclick.

Share Improve this question edited Jul 30, 2020 at 9:35 Vishal Tarkar 82611 silver badges32 bronze badges asked Apr 27, 2018 at 5:23 debratadebrata 1391 gold badge7 silver badges17 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

With Below code you can know more about your current route.

$route = Route::current();

$name = Route::currentRouteName();

$action = Route::currentRouteAction();

Reference : Link

Hope it will help!

Best way to get current url in Laravel blade:

onclick="window.location='{{ Request::url() }}'"

You can reload current page like this:

onclick="window.location.reload()"

There is no need to set current route in blade it's possible with javascript abilities.

发布评论

评论列表(0)

  1. 暂无评论