thinkphp6 视图输出字符串替换 view_replace_str,__PUBLIC__ 无效
2022-07-28 14:14:58
260
{{single.collect_count}}

踩了个坑,thinkphp5.0 及之前版本,都是在配置文件配置

 'view_replace_str' => [        '__PUBLIC__'   =>  '/',    // 路径自己定义        '__STATIC__'   =>  '/static'    ],


 

但,thinkphp5.1及之后版本,都是使用  tpl_replace_string
 

 'tpl_replace_string' => [ // 视图输出字符串内容替换        '__PUBLIC__'   => '/',    //路径自己定义    ],

配置成功后,在模板文件输出:

<link rel="stylesheet" href="__PUBLIC__/common/css/reset.css"><script src="__PUBLIC__/common/js/jquery-1.12.4.min.js"></script>


注意:如果还是不成功,可能是缓存原因,先将模板缓存关闭

'tpl_cache'   => false,


 

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}