5dmatweblogin / ajaxlogin
Ajax 登录用于 Laravel ...
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2024-09-18 20:16:19 UTC
README
laravel ajax 登录行 JavaScript
#视频 视频在这里
#安装 将此命令添加到 Linux 或 macOS 的终端或 Windows 的 cmd
composer require 5dmatweblogin/ajaxlogin:dev-master
#添加提供者 在 config/app.php 的提供者数组中添加此行
AjaxLogin\AjaxLoginProvider\AjaxLoginProvider::class,
#身份验证脚手架 在终端中添加此行
php artisan make:auth
#发布 Vendors 不是最后一步,我们将此行写入 login.blade.php、app.blade.php、logincontroller.php,并在公共路径 /public/AjaxLogin/AjaxLogin.js 中添加新文件
php artisan vendor:publish --tag=5dmatweb --force
#现在开始 现在开始你的项目并享受 Ajax 登录
php artisan serve
#如何使用 我们已经在登录文件和应用程序布局文件中为你设置了所有内容,这是基础
AL = new Login({ email:"email", password:"password", btn:"btn", url:"/login", ///where we post the form data successUrl:"/",/// url to redirect after login /home is the default mode:"toast" ///alert or toast });
email => 设置邮箱 ID 字段
password => 设置密码 ID 字段
btn => 设置提交按钮 ID 字段
url => 登录 POST URL,默认设置为 /login
successUrl => 成功登录后我们将用户重定向到的 URL。默认情况下,我们重定向到主页
mode => 显示错误的方式,我们有两种模式:示例弹窗或 toast 弹窗
#方法
#完成登录 我们有一个名为 doneLogin 的方法,用于处理用户登录后的操作。如果您想添加自定义逻辑,可以在这里添加,默认操作是重定向到主页或如果设置了 successUrl 属性,库将重定向用户到该 URL
AL.doneLogin = function(){ alert('login'); };
#错误登录 我们有一个名为 errorLogin 的方法,用于处理登录错误,例如登录信息错误。如果您想添加自定义逻辑,可以在这里添加。默认操作是在用户模式下显示错误,您可以运行自定义错误显示,如果需要,函数将返回 Laravel 传递的错误
AL.errorLogin = function (error) { console.log(error) };