【问题标题】:ClientDependency in umbraco doesn't include my bundlesumbraco 中的 ClientDependency 不包括我的捆绑包
【发布时间】:2017-02-01 04:19:28
【问题描述】:

这里是我调用 BundleManager 的地方:

public class MyUmbracoApplication : UmbracoApplication
{ 
    protected override void OnApplicationStarted(object sender, System.EventArgs e)
    {
        //register custom routes
        RouteConfig.RegisterRoutes(RouteTable.Routes);

        CreateBundles();

        base.OnApplicationStarted(sender, e);
    }

    public static void CreateBundles()
    {
        BundleManager.CreateCssBundle("css",
            new CssFile("~/css/rte.css"));

        BundleManager.CreateJsBundle("js",
            new JavascriptFile("/assets/js/custom.js"));
    }
}

这里是我调用捆绑包的地方(我的 Master.cshtml 页面的底部):

 <div class="test">
        @{
            Html.RequiresJsBundle("js");
            Html.RequiresCssBundle("css");
         }
    </div>

这是我得到的:

我的客户端依赖临时 xmp 文件的内容:

<?xml version="1.0" encoding="utf-8" standalone="yes"?><map />

我授予每个人(在本地)的完全访问权限,文件与文件夹具有相同的证券(assets/css、assets/js)

我有标准的 ClientDependency.config 文件。

我做错了什么?

【问题讨论】:

  • 您是否尝试过将捆绑包重命名为不同的名称..

标签: asp.net-mvc umbraco umbraco7 client-dependency


【解决方案1】:

我终于想通了。 Html.RequiresJsBundle("customjs1") 只是使当前页面依赖于捆绑包,您仍然需要使用 Html.RenderJsHere 来输出脚本标签。

来源:https://github.com/Shazwazza/ClientDependency/issues/1

这是我渲染包的方式:

Html.RequiresJsBundle("customjs1"); // at the top of the page, inside @{}

@Html.RenderJsHere() // where the js needs to be rendered - at the bottom of the page for me

【讨论】:

  • 嗨 @Giu 我可以每页有两个加载器 js,一个在头上,一个在底部,因为我有两个 JS Bundle thanx Esmeraldi
  • 嗨 Esmeraldi,这是相同的逻辑,您只需要调用 'Html.Requires..' 2 次(每个包一个),然后调用 Html.RenderJsHere('bundle1') 和 Html。 RenderJsHere('bundle2')。看第267行github.com/Shazwazza/ClientDependency/blob/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-07-07
  • 2016-01-26
  • 2021-02-09
  • 2014-11-03
  • 2023-03-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多