ThinkPHP中自定义错误、成功、异常提示页面的方法

简介ThinkPHP提供了自带的错误提示页面,但是并不美观,提示信息显示如下:我们如果想要更换提示页面应该怎么做呢?以ThinkPHP3.2为例:在应用配置文件(应用文件目录/Common/Conf/config.php)中添加:/*错误页面模板*/’TMPL_ACTION_ERROR’=>’Public/dispatch_jump.html’,//默认错误跳转对应的模板文件”TMPL_ACTION

  

ThinkPHP提供了自带的错误提示页面,但是并不美观,提示信息显示如下:

ThinkPHP中自定义错误、成功、异常提示页面的方法

我们如果想要更换提示页面应该怎么做呢?

以ThinkPHP3.2为例:

在应用配置文件(应用文件目录/Common/Conf/config.php)中添加:

/*错误页面模板*/'TMPL_ACTION_ERROR'=>'Public/dispatch_jump.html',//默认错误跳转对应的模板文件''TMPL_ACTION_SUCCESS'=>'Public/dispatch_jump.html',//默认成功跳转对应的模板文件'//'TMPL_EXCEPTION_FILE'=>'Public/exception.html',//异常页面的模板文件

然后我是在项目公共文件(项目目录/Public)中新建了dispatch_jump.html,模板内容如下:

<!DOCTYPEhtml><html><head>< http-equiv="Content-Type"content="text/html;charset=utf-8"/>< >跳转提示</ >< name="viewport"content="width=device-width,initial-scale=1.0"><styletype="text/css">*{box-sizing:border-box;margin:0;padding:0;font-family:LantingheiSC,OpenSans,Arial,HiraginoSansGB,MicrosoftYaHei,"微软雅黑",STHeiti,WenQuanYiMicroHei,SimSun,sans-serif;-webkit-font-smoothing:antialiased}body{padding:70px0;background:#edf1f4;font-weight:400;font-size:1pc;-webkit-text-size-adjust:none;color:#333}a{outline:0;color:#3498db;text-decoration:none;cursor:pointer}.system-message{margin:20px5%;padding:40px20px;background:#fff;box-shadow:1px1px1pxhsla(0,0%,39%,.1);text-align:center}.system-messageh1{margin:0;margin-bottom:9pt;color:#444;font-weight:400;font-size:40px}.system-message.jump,.system-message.image{margin:20px0;padding:0;padding:10px0;font-weight:400}.system-message.jump{font-size:14px}.system-message.jumpa{color:#333}.system-messagep{font-size:9pt;line-height:20px}.system-message.btn{display:inline-block;margin-right:10px;width:138px;height:2pc;border:1pxsolid#44a0e8;border-radius:30px;color:#44a0e8;text-align:center;font-size:1pc;line-height:2pc;margin-bottom:5px;}.success.btn{border-color:#69bf4e;color:#69bf4e}.error.btn{border-color:#ff8992;color:#ff8992}.info.btn{border-color:#3498db;color:#3498db}.copyrightp{width:100%;color:#919191;text-align:center;font-size:10px}.system-message.btn-grey{border-color:#bbb;color:#bbb}.clearfix:after{clear:both;display:block;visibility:hidden;height:0;content:"."}@media(max-width:768px){body{padding:20px0;}}@media(max-width:480px){.system-messageh1{font-size:30px;}}</style></head><body><divclass="system-messageerror"><?phpif(isset($message)){?><divclass="image"><imgsrc="http://cdn.demo.fastadmin.net/assets/img/success.svg"alt=""width="150"/></div><h1><?phpecho$message;}else{?><divclass="image"><imgsrc="http://cdn.demo.fastadmin.net/assets/img/error.svg"alt=""width="150"/></div><h1><?phpecho$error;}?></h1><pclass="jump">页面将在<spanid="wait"><?phpecho($waitSecond);?></span>秒后自动<aid="href"href="<?phpecho($jumpUrl);?>">跳转</a></p><pclass="clearfix"><ahref=" :history.go(-1);"class="btnbtn-grey">返回上一步</a><ahref="<?phpecho($jumpUrl);?>"class="btnbtn-primary">立即跳转</a></p></div>< type="text/ ">(function(){varwait=document.getElementById('wait'),href=document.getElementById('href').href;varinterval=setInterval(function(){vartime=--wait.innerHTML;if(time<=0){location.href=href;clearInterval(interval);}},1000);})();</ ></body></html>

效果如下:

ThinkPHP中自定义错误、成功、异常提示页面的方法

以上就是ThinkPHP中自定义错误、成功、异常提示页面的方法的详细内容。希望对大家有所帮助~~

下载链接:网站源码/小程序源码/网站模板下载

版权声明

   站内部分内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供网络资源分享服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请 联系我们 一经核实,立即删除。并对发布账号进行永久封禁处理。在为用户提供最好的产品同时,保证优秀的服务质量。


本站仅提供信息存储空间,不拥有所有权,不承担相关法律责任。

给TA打赏
共{{data.count}}人
人已打赏
网站技巧

html5的drag和drop的用法示例

2024-9-19 19:43:51

网站技巧

phpmyadmin如何重置密码?

2024-9-19 19:43:53

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索