在blade中,如果我们想检查当前路由是否与路由匹配,我们可以简单地使用:
@if(Route::currentRouteName() == 'parameter')
{{ 'yes' }}
@else
{{ 'no' }}
@endif
Run Code Online (Sandbox Code Playgroud)
但是如果我们想将它与通配符匹配怎么办:
@if(Route::currentRouteName() == 'parameter.*')
{{ 'yes' }}
@else
{{ 'no' }}
@endif
Run Code Online (Sandbox Code Playgroud)
有什么解决办法吗?
我试过 "*" 和 ":any",但没有用。
注意:我想检查路由,而不是 URL。
任何帮助,将不胜感激。
谢谢,
帕斯沃拉
使用 Laravel 的字符串辅助函数
str_is('parameter*', Route::currentRouteName())
Run Code Online (Sandbox Code Playgroud)
对于任何以 parameter
| 归档时间: |
|
| 查看次数: |
1240 次 |
| 最近记录: |