页面跳转
1、方法存在的文件路径
TP5\thinkphp\library\traits\controller\Jump.php
成功跳转 $this->success();
失败跳转 $this->error();
2、以登录功能为例:
login.php
<?php namespace app\index\controller; use\think\Controller; class Login extends Controller{ public function login(){ return view(); } public function check(){ $username = $_POST['username']; $password = $_POST['password']; if($username=="admin"&&$password=="123"){ //$this->success(提示信息,跳转的URL地址(默认到登陆界面), //用户需要返回的数据,跳转时间) $this->success("成功","user/index","","1"); }else{ //$this->error(提示信息,跳转的URL地址(默认到登陆界面), //用户需要返回的数据,跳转时间) //$this->error("失败"); //redirect('跳转地址','其他参数',code,'隐士参数');重定向 $this->redirect('user/index',['id'=>100,'name'=>'abc']); } } //空操作 public function _empty(){ $this->redirect('index/index'); } } ?>