success一直是一个空白页面,这是为什么
<?php
namespace app\demo\controller;
use think\Db;
use think\Controller;
use app\demo\model\User;
class Index extends Controller
{
public function index()
{
$data = ['id' => '', 'data' => getRandChar(26)];
$res = Db::name('data')->insert($data);
if($res == 1){
//设置成功后跳转页面的地址,默认的返回页面是$_SERVER['HTTP_REFERER']
$this->success('新增成功', 'User/list');
} else {
//错误页面的默认跳转页面是返回前一页,通常不需要设置
$this->error('新增失败');
}
} 最佳答案