我在工作中使用 ASP.NET MVC3,而在家中使用 PHP。我想在 CodeIgniter 中使用 MVC3 的 Sections 功能,它有这样的功能吗?
ASP.NET MVC3 中的示例(未测试):
<!-- A view, that serves the content -->
@section Head{
<script src="myscript.js"></script>
}
<p>This is my main content -
I require myscript.js to be included on my page,
so I specify a head section, which the header of my page will render</p>
<!-- ANOTHER view, that serves the content -->
@section Head{
<script src="otherscript.js"></script>
<link rel="stylesheet" type="text/css" href="somestyle.css" />
}
<p>Some OTHER view, with OTHER dependencies!</p>
<!-- Header File, where I include CSS and JS! -->
<head>
<script src="jquery.js"></script>
@Html.Section("Head")
</head>
重点是,例如,在特定视图中,我希望包含一个脚本文件,因此我将 添加<script>
到该部分,并且该部分呈现在标题中(在不同的视图中)