2
4

1 回答 1

4

您是否尝试过将其用作 JArray?

@using Newtonsoft.Json.Linq
@{      
    if (Model.Content.HasValue("relatedLinks") && Model.Content.GetPropertyValue<string>("relatedLinks").Length > 2)
    {
        <ul>
            @foreach (var item in Model.Content.GetPropertyValue<JArray>("relatedLinks"))
            {
                var linkUrl = (item.Value<bool>("isInternal")) ? Umbraco.NiceUrl(item.Value<int>("internal")) : item.Value<string>("link");
                var linkTarget = item.Value<bool>("newWindow") ? "_blank" : null;
                <li><a href="@linkUrl" target="@linkTarget">@(item.Value<string>("caption"))</a></li>
            }
        </ul>
    }
}  

https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/related-links

于 2015-09-21T08:01:37.343 回答