ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
**TP6 图形验证码** ``` 安装: composer require topthink/think-captcha 生成验证码: namespace app\admin\controller; use app\BaseController; use think\captcha\facade\Captcha; class Login extends BaseController public function verify() { ob_clean();//清除缓存,记得加上 return Captcha::create(); } } html页面使用: <img src="{:url('login/verify')}" id="LAY-user-get-vercode"> 点击切换验证码(js文件): $("#LAY-user-get-vercode").click(function () { var src = "/login/verify"; $(this).attr('src', src + "?" + Math.round(Math.random() * 1000)); }); 注意事项: * 验证码库需要开启Session才能生效:middleware.php中开启 \think\middleware\SessionInit::class * ob_clean();//清除缓存,记得加上 ```