2016-01-17 101 views
1

在我的MVC應用程序中,我想使用require.js。我正在嘗試使用以下方法;通過Scripts.Render添加自定義屬性到腳本標記

@Scripts.Render("~/bundles/require") 

在require.js文檔中記錄爲;

<!--This sets the baseUrl to the "scripts" directory, and 
    loads a script that will have a module ID of 'main'--> 
<script data-main="scripts/main.js" src="scripts/require.js"></script> 

所以我需要設置數據主要= 「腳本/ main.js」 在MVC部分部分。

我該如何通過Scripts.Render函數來添加額外的屬性?

回答

1

發現需要使用以下方法;

@Scripts.RenderFormat("<script type=\"text/javascript\" data-main=\"/JavaScript/main.js\" src=\"{0}\"></script>", "~/bundles/require")