1 |
{{ strstr(Route::getCurrentRoute()->getPath(),$item->url) ? 'class=active' : ''}} |
strstr 函数还有个坑,如果第二个参数 $item->url 是 empty 会报错,NULL 不会报错,Laravel 中 NULL 跟 empty 的坑参见这个帖子。
1 |
{{ strstr(Route::getCurrentRoute()->getPath(),$item->url) ? 'class=active' : ''}} |
strstr 函数还有个坑,如果第二个参数 $item->url 是 empty 会报错,NULL 不会报错,Laravel 中 NULL 跟 empty 的坑参见这个帖子。