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