gpt4 book ai didi

html - Umbraco 截断

转载 作者:搜寻专家 更新时间:2023-10-31 23:18:46 29 4
gpt4 key购买 nike

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 作为第一个参数。

关于html - Umbraco 截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48170201/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com