thinkphp6 返回json数据封装
2022-11-24 11:10:29
231
{{single.collect_count}}

代码

写入公共文件  tp>app>common.php

<?php// 这是系统自动生成的公共文件//function_exists('success')判断是否有这个文件//成功时调用if(!function_exists('success')){function success($code,$mes,$data){return json(['code'=>$code,'mes'=>$mes,'data'=>$data,]);}}//失败时调用if(!function_exists('error')){function error($code,$mes,$data){return json(['code'=>$code,'mes'=>$mes,'data'=>$data,]);}}

调用 

//成功时调用return success(200,'登录成功',null);//失败时调用return error(300,'登录失败',null);

回帖
全部回帖({{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 ? '加载中...' : '查看更多评论'}}