thinkphp6的容器和服务使用理解
2022-11-24 11:10:29
142
{{single.collect_count}}

容器的简单使用:

1.在extend目录自定义一个类

使用容器绑定类并且使用

结果:

因此可以把容器理解为:用来把类放进去然后使用app()调用的,

服务:

1.生成一个服务类

2.绑定类到容器

3.添加服务

4.使用

6.结果

因此,服务也是用来bind类的

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