我有一个剃刀视图,我想使用剃刀子组件。我的主要剃刀文件看起来像这样
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Contentpage>
@using ContentModels = Umbraco.Web.PublishedContentModels;
@{
Layout = "master.cshtml";
var components = new List<Bodytext>();
if (Model.Content.Mixed != null && Model.Content.Mixed.Any()) {
components = Model.Content.Mixed.Select(e => new Bodytext(e)).ToList();
}
}
<div>contentpage</div>
<ul class="team__employee-list">
@foreach (var component in components){
if (component.IsDocumentType("Banner")) {
<li>
@component.Title 1
@Html.Partial("Components/cmp-banner", component)
</li>
}
if (component.IsDocumentType("BodyText")) {
<li>
@component.Title 2
</li>
}
}
</ul>
和我的子组件一样
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
<div>@model.Title</div>
但我收到此错误
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The 'inherits' keyword is not allowed when a 'model' keyword is used.
Source Error:
Line 1: @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
Line 2:
Line 3: <div>banner</div>
答案 0 :(得分:0)
我明白了。它必须是
@Model.Content.GetPropertyValue("Title")