請教一個問題,關于{{url('url')}}
你好,我laravel 5.6
web.php 中路由的定義?
Route::get('/student/urlTest',['as'=>'urlTest','uses' => 'studentController@urlTest']);
我在測試view視圖中url用法時,發現url()路徑有些問題,
<a href="{{url('urlTest')}}">URL</a>
輸出:http://192.168.1.50/laravel/public/urlTest? ?,錯誤路徑,無法輸出數據
? ? <p></p>
? ? <a href="{{action('studentController@urlTest')}}">action</a>
輸出:http://192.168.1.50/laravel/public/student/urlTest? ?可以正確訪問輸出數據
? ? <p></p>
? ? <a href="{{route('urlTest')}}">route</a>
輸出:http://192.168.1.50/laravel/public/student/urlTest? ?可以正確輸出數據。
請問第一個是什么原因訪問不到數據?
2022-05-19
url參數是路由名稱? action參數是控制器加函數名? route參數是路由別名? 所以正確的url用法應該是url('/student/urlTest')
2018-08-12
沒有用全名,應該是<a href="{{url('/student/urlTest')}}">URL</a>