尝试在嵌套内容中渲染来自 MAP 的节点;收到错误“...不包含 'GetPropertyValue' 的定义”

Triyng to render nodes from MNTP in nested content; getting error "... does not contain a definition for 'GetPropertyValue'"

我有用于嵌套内容的文档类型。它有一个 MNTP 属性,我在渲染选取的节点时遇到问题。

See screenshot of document type

我收到错误:“'Umbraco.Web.PublishedContentModels.Site_nested_contactGroup' 不包含 'GetPropertyValue'”的定义“

这段代码在我看来是:

var items = CurrentPage.GetPropertyValue<IEnumerable<IPublishedContent>>("contactpersons");
foreach(var item in items)
{
    var persons = item.GetPropertyValue<IEnumerable<IPublishedContent>>("persons");
    <h2>@Umbraco.Field(item, "headline")</h2>
    foreach (string contactperson in persons)
    {
        .... render contactperson....
    }   
}

而不是这个:

var items = CurrentPage.GetPropertyValue<IEnumerable<IPublishedContent>>("contactpersons");
foreach(var item in items)
{
    var persons = item.GetPropertyValue<IEnumerable<IPublishedContent>>("persons");
    <h2>@Umbraco.Field(item, "headline")</h2>
    foreach (string contactperson in persons)
    {
        .... render contactperson....
    }   
}

试试:

var items = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("contactpersons");
foreach(var item in items)
{
    var persons = item.GetPropertyValue<IEnumerable<IPublishedContent>>("persons");
    <h2>@Umbraco.Field(item, "headline")</h2>
    foreach (string contactperson in persons)
    {
        .... render contactperson....
    }   
}