0

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

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

在 nopcommerce 中,header.cshtml 中有一行。IE

@html.widget("header_selectors")

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

4

1 回答 1

2

你可以看看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 });
}

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

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

于 2017-08-17T09:10:53.973 回答