什么是nopcommerce中的@html.widget?



我想知道nopcommerce中的@html.widget是什么。 它有什么用?我们为什么使用它?

在NopCommerce中,@html.widget被使用了很多地方,让我们谈论一个地方在header.cshtml页面中。

在nopcommerce中,header.cshtml中有一行,即

@html.widget("header_selectors")

现在,问题是这条线的目的是什么。因为当我删除此行时,客户端没有任何变化。那么为什么header.cshtml页面中给出它。

你可以看看Nop.Web.Framework/HtmlExtensions

public static MvcHtmlString Widget(this HtmlHelper helper, string widgetZone, object additionalData = null, string area = null)
{
return helper.Action("WidgetsByZone", "Widget", new { widgetZone = widgetZone, additionalData = additionalData, area = area });
}

此扩展调用小部件控制器上的操作,该控件使用小部件服务查找为指定小部件区域提供附加内容的所有插件。

例如,您可能希望在不接触主题的情况下向页脚添加内容。因此,您可以创建一个小部件插件,将内容添加到"页脚"区域。

最新更新