2016-01-17 102 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")