一、创建控制器
<?php namespace app\common\taglib; use think\auth\Auth; use think\template\TagLib; class MyTag extends TagLib { protected $tags = [ 'auth' => ['attr' => 'rule', 'close' => 1] ]; /** * 权限判断标签 * @param $tag * @param $content * @return string */ public function tagAuth($tag, $content) { $rule = $tag['rule']; $auth = new Auth(); $uid = session('uid'); $res = $auth->check($rule, $uid); $parseStr = '<?php if(' . intval($res) . '): ?>' . $content .'<?php endif; ?>'; return $parseStr; } }
二、配置
三、使用
{auth rule='Group/index'} <a href="{:url('Group/index')}">用户组</a> {/auth}
标签:uid,自定义,标签,auth,content,TP5,tag,rule From: https://www.cnblogs.com/yang-2018/p/18003240