Laravel 4-了解View :: share() [英] Laravel 4 - understanding View::share()
本文介绍了Laravel 4-了解View :: share()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
据我了解:
View::share('foo','bar');
将使$ foo在所有视图中可用.
Will make $foo available in all views.
但是,说View::share()
只能在__construct()
中使用是正确的吗?
However, is it correct to say View::share()
can be used only in the __construct()
?
由于来自外部__construct()
,我无法使其正常工作.
Because from outside __construct()
I can't make it to work.
推荐答案
View::share
应该在您的应用程序中的任意位置可用.在视图编辑器中通常会使用它,但是它应该可以在路线中或任何需要的地方使用.
View::share
should be available anywhere within your application. A common place that it is used is in view composers, but it should be usable within a route or wherever you need it.
这篇关于Laravel 4-了解View :: share()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文