ThinkPHP 6 添加跳转提示扩展 liliuwei/thinkphp-jump的操作方法

 更新时间:2023年08月02日 14:21:00   作者:wkj001  
liliuwei/thinkphp-jump 是 TP5 中经典跳转提示,在 TP6 中已经取消,通过 composer 下载该扩展可以在 TP6 中使用 TP5 的跳转提示操作,这篇文章主要介绍了ThinkPHP 6 添加跳转提示扩展 liliuwei/thinkphp-jump,需要的朋友可以参考下

liliuwei/thinkphp-jump 是 TP5 中经典跳转提示,在 TP6 中已经取消,通过 composer 下载该扩展可以在 TP6 中使用 TP5 的跳转提示操作。

在这里插入图片描述

安装扩展

在应用根目录执行:

composer require liliuwei/thinkphp-jump

引入扩展

在全局配置目录生成 jump.php 文件:

return[
    // 默认跳转页面对应的模板文件
    'dispatch_success_tmpl' => app()->getRootPath().'/vendor/liliuwei/thinkphp-jump/src/tpl/dispatch_jump.tpl',
    'dispatch_error_tmpl'   => app()->getRootPath().'/vendor/liliuwei/thinkphp-jump/src/tpl/dispatch_jump.tpl',
];

使用扩展

<?php
namespace app\controller;
class Index 
{
    // 在控制器中引入 Jump
    use \liliuwei\think\Jump; 
    public function index(){
        return  $this->success('成功','跳转地址');
        return  $this->error('失败','跳转地址');
    }
}

到此这篇关于ThinkPHP 6 添加跳转提示扩展 liliuwei/thinkphp-jump的文章就介绍到这了,更多相关ThinkPHP跳转扩展内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

最新评论