能往路由訪問的接口里面?zhèn)鲄?shù)嗎?
Route::any('/product', [app\index\controller\Index::class, 'product']);
http://m.wtbis.cn/doc/webman/route.html
如果路由中存在參數(shù),通過{key}來匹配,匹配結(jié)果將傳遞到對應(yīng)的控制器方法參數(shù)中(從第二個參數(shù)開始依次傳遞),例如:
// 匹配 /user/123 /user/abc
Route::any('/user/{id}', [app\controller\User:class, 'get']);
namespace app\controller;
class User
{
public function get($request, $id)
{
return response('接收到參數(shù)'.$id);
}
}