本布拉科截断



Umbraco Truncate对我来说似乎不是工作,当我使用正确的代码时,它不断出错(根据互联网(。我不知道它有什么问题。

错误代码:

Compiler Error Message: CS1502: The best overloaded method match for 'Umbraco.Web.UmbracoHelper.Truncate(System.Web.IHtmlString, int)' has some invalid arguments

法典:

<div class="grid-item col-xs-12 col-sm-6 col-md-4">
                <figure>
                    <a href="@item.Url">
                        @if (@item.GetPropertyValue("image") != null)
                        {
                            <img src="@Umbraco.Media(item.GetPropertyValue("image").ToString()).Url?anchor=center&mode=crop&w=400&h=275"/>
                        <figcaption>
                            <h5>@item.GetPropertyValue("title")</h5>
                            <p>@Umbraco.Truncate(item.GetPropertyValue("intro"),200)</p>
                        </figcaption>
                        }
                        else
                        {
                            <figcaption>
                                <h5>@item.GetPropertyValue("title")</h5>
                                <p>@item.GetPropertyValue("intro")</p>
                            </figcaption>
                        }
                    </a>
                </figure>
            </div>

不知道为什么<p>@Umbraco.Truncate(item.GetPropertyValue("intro"),200)</p>不起作用

它应该是

@Umbraco.Truncate(item.GetPropertyValue<string>("intro"), 200);

而不是

@Umbraco.Truncate(item.GetPropertyValue("intro"), 200);

因为item.GetPropertyValue("intro")object 类型,你需要string作为第一个参数。

最新更新