1、html 写法
<form action="{:url('index/search')}" method="get">
<input type="text" name='search' value=""/>
<input type="submit" value=""/>
</form>2、服务端写法<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
class Index extends Controller
{
public function search() {
echo 243455;
}
3、路由定义写法<?php
return [
'__pattern__' => [
'name' => '\w+',
],
'[hello]' => [
':id' => ['index/hello', ['method' => 'get'], ['id' => '\d+']],
':name' => ['index/hello', ['method' => 'post']],
],
'/ncate/:id' =>[
'news/lists', ['method' => 'get'], ['ext'=>'html'],['id' => '\d+']
],
'/news/lists' =>[
'news/lists', ['method' => 'get'], ['ext'=>'html'],['id' => '\d+']
],
'/news' =>[
'news/index', ['method' => 'get'], ['ext'=>'html']
],
'/ncon/:id' =>[
'news/con', ['method' => 'get'], ['ext'=>'html'],['id' => '\d+']
],
'/' =>[
'index/index', ['method' => 'get']
],
'/:dir/[:pdir]' =>[
'cate/index', ['method' => 'get'],['ext'=>'html'],['id' => '\d+']
],
'/index/newscate' =>[
'index/newscate', ['method' => 'get'], ['ext'=>'html'],['id' => '\d+']
],
'/indexs/:id' =>[
'index', ['method' => 'get'], ['ext'=>'html'],['id' => '\d+']
],
'/conlist/con/:id' =>[
'conlist/con', ['method' => 'get'], ['ext'=>'html'],['id' => '\d+']
],
'/content/:id' =>[
'content/index', ['method' => 'get'], ['ext'=>'html'],['id' => '\d+']
],
'/conios/:id' =>[
'con/index', ['method' => 'get'], ['ext'=>'html'],['id' => '\d+']
],
'/conan/:id' =>[
'con/android', ['method' => 'get'], ['ext'=>'html'],['id' => '\d+']
],
'/conpc/:id' =>[
'con/pc', ['method' => 'get'], ['ext'=>'html'],['id' => '\d+']
],
'/conipad/:id' =>[
'con/ipad', ['method' => 'get'], ['ext'=>'html'],['id' => '\d+']
],
'/conanipad/:id' =>[
'con/anipad', ['method' => 'get'], ['ext'=>'html'],['id' => '\d+']
],
'/catelist/:cateid' =>[
'catelist/index', ['method' => 'get'], ['ext'=>'html'],['cateid' => '\d+']
],
'/headertop/:id' =>[
'index/headertop', ['method' => 'get'], ['ext'=>'html'],['id' => '\d+']
],
'/index/search' =>[
'index/search', ['method' => 'get'], ['ext'=>'html']
],
];结果 ,无论如何 也 无法触发 function search 方法 , 无法输出数字?请问大牛们 ,问题 出在哪里?
因为 设置了路由后, function search 方法直接没有进入!!!
而我 也没有看出 路由设置的冲突来!!!
最佳答案