2016-09-23 5 views
1

が含まれていません、私はBundleManagerを呼ぶところである:私は(私のMaster.cshtmlのページの一番下)のバンドルを呼び出すのはここClientDependencyはここに私のバンドル

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")); 
    } 
} 

は次のとおりです。

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

は私が得るものです:

enter image description here

の内容私clientdependency一時XMPファイル:

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

私は(ローカルの)みんなへのフルアクセスを与えた、ファイルはフォルダと同じ有価証券を保有してい(資産/ CSS、資産/ JSの)

私は標準を持っていますClientDependency.configファイル。

どうしたのですか?

+0

あなたが別の何かにバンドルの名前を変更するtridedました.. –

答えて

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 
+0

ハイテク@Giu私は、ページごとに1つ2つのローダーJSを持つことができます私は2つのJSバンドルを持っているので、ヘッドと1つの底にある –

+0

こんにちはEsmeraldi、それは同じロジックです、あなたは 'Html.Requires ..'を2回(各バンドルに1つ)呼んで、Html.RenderJsHere 'bundle1')とHtml.RenderJsHere( 'bundle2')があります。 267行目をご覧ください https://github.com/Shazwazza/ClientDependency/blob/b5ba8cf6fbe476365b948888478e4389dbd0f710/ClientDependency.Mvc/HtmlHelperExtensions.cs – Giu