解决thinkphp5 报错返回variable type error: array
2023-03-29 23:03:03
119
{{single.collect_count}}

问题

thinkphp5 报错返回variable type error: array

public function test(){$data = ['result' => 1];return $data;}

return 返回数组,就会报 错:variable type error: array

解决办法

解决办法:用json() 函数返回

public function test(){$data = ['result' => 1];return json($data);}
回帖
全部回帖({{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 ? '加载中...' : '查看更多评论'}}