1.在application中下的config.php中
以下代码改为true
// 是否开启路由
'url_route_on' => true,
// 是否强制使用路由
'url_route_must' =>true,
然后在route.php中定义路由
ps:把初始化的那些代码删除,不然无法使用路由 注意一定要加上 use think\Route;
<?php
use think\Route;
Route::get('/home/:name',function ($name){
return '你的姓名是:'.$name;
});
放一张图显示结果 注意路由的写法

来源:https://www.cnblogs.com/yaoliuyang/p/12298780.html