我想为我的偏见视图使用不同的模型,如何做到这一点?你有例子吗?
<div id="tabs">
<ul>
<li><a href="#tabs-1">first tab</a></li>
<li><a href="#tabs-2">second tab</a></li>
<li><a href="#tabs-3">third tab</a></li>
</ul>
<div id="tabs-1">
@{Html.RenderPartial("FirstTabView", Model)}
</div>
<div id="tabs-2">
@{Html.RenderPartial("SecondTabView", Model)}
</div>
<div id="tabs-3">
@{Html.RenderPartial("ThirdTabView", Model)}
</div>
</div>
答案 0 :(得分:2)
您可以将子模型作为主模型的一部分,例如:
public class YourModel
{
public FirstTabModel FirstTab { get; set; }
public SecondTabModel SecondTab { get; set; }
public ThirdTabModel ThirdTab { get; set; }
}
然后你可以这样做:
<div id="tabs-1">
@{Html.RenderPartial("FirstTabView", Model.FirstTab)}
</div>
<div id="tabs-2">
@{Html.RenderPartial("SecondTabView", Model.SecondTab)}
</div>
<div id="tabs-3">
@{Html.RenderPartial("ThirdTabView", Model.ThirdTab)}
</div>