在我的 MVC 应用程序中,我想使用 require.js 。我正在尝试使用以下方式;
@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>
所以我需要在 MVC 部分设置 data-main="scripts/main.js" 部分。
如何通过 Scripts.Render 函数添加额外的属性?
最佳答案
发现需要使用以下方式;
@Scripts.RenderFormat("<script type=\"text/javascript\" data-main=\"/JavaScript/main.js\" src=\"{0}\"></script>", "~/bundles/require")
关于javascript - 通过 Scripts.Render 将自定义属性添加到脚本标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34844686/