php - 在路由函数中读取刀片变量
问题描述
我在 Laravel 中有一个系统,当我在视图中构建带有链接的模板时,我需要像这样动态插入一个路由:
<ul class="breadcrumbs pull-left">
<li><a href="{{route('home')}}">Home</a></li>
<li><a href="{{route('$route.index')}}">{{$title}}</a></li>
<li><span>{{$activeList}}</span></li>
</ul>
如何在路由函数中读取刀片变量?
这不起作用:
{{route('$route.index')}}
错误:“未定义路由 [$active.index]。(查看:C:\xampp\htdocs\systemass\resources\views\templates\srtdash\inc\pagearea.blade.php)(查看:C:\xampp\htdocs \systemass\resources\views\templates\srtdash\inc\pagearea.blade.php)(查看:C:\xampp\htdocs\systemass\resources\views\templates\srtdash\inc\pagearea.blade.php
解决方案
只需使用变量内容
<ul class="breadcrumbs pull-left">
<li><a href="{{route('home')}}">Home</a></li>
<li><a href="{{route($active.'.index')}}">{{$title}}</a></li>
<li><span>{{$activeList}}</span></li>
</ul>
推荐阅读
- python - 是什么导致动态创建的 gif 中的伪影?
- c# - 使用 PathBase 执行 ASP.NET 操作
- scala - Scalatest 失败,出现错误“java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z”
- python - python校验和或哈希每次执行都需要相同的输出
- laravel - 如何在 laravel 中使用 hasMany 获取用户最后一条消息
- python - 如何根据 Django 中的用户获取产品?
- c# - 在 localhost IIS Web 服务器中运行 cmd.exe 命令不起作用
- java - 如何在recyclerview中显示arraylist数据?
- java - Graphics2d 制作一个盒子
- ios - 在通道 stripe_payment IOS 上找不到方法 createSourceWithParams 的实现