@include ('topics._reply_box', ['topic' => $topic]) 这种写法 [ ] 是起到什么作用的?

@include ('topics._reply_box', ['topic' => $topic]),这个 [ ] 是干嘛用的,没啥用处呀

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
最佳答案

如果你写成,@include('topics._reply_box', ['foo' => $topic]), 你就可以在 topics._reply_box 视图中得到一个 $foo , 此 $foo$topic 是一样的,所以相当于给 $topic 取了个别名,传递到 topics._reply_box 视图中

6年前 评论
讨论数量: 3
sunxyw

这个的作用是把 $topic 变量传给 topics._reply_box

6年前 评论

如果你写成,@include('topics._reply_box', ['foo' => $topic]), 你就可以在 topics._reply_box 视图中得到一个 $foo , 此 $foo$topic 是一样的,所以相当于给 $topic 取了个别名,传递到 topics._reply_box 视图中

6年前 评论

[] 是数组 array () 的简写呀,这里就是把渲染页面的数据传入要加载的模块了

6年前 评论