我正在尝试获取用于 Bootstrap 的 requireJS 垫片,但我遇到了一些麻烦。
每当我在 visual studio 中运行它时,它都会因为新的 __vwd/js/artery
javascript(Visual Studio 注入(inject)到页面中)也引用 JQuery 而中断。
有没有办法让我的 requireJS shim 与 artery 一起工作?
下面是一些示例 html,它将重现该问题(如果您直接在浏览器中打开它,它工作正常,但如果您通过 Visual Studio 运行它,它会中断(在我的例子中,我在 MVC 应用程序中运行它)
我可以通过禁用 artery 来解决这个问题,但我正在寻找的是一种使其保持启用状态并且还能够设置我的 shim 的方法。
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<script>
var require = {
paths: {
"jquery": "http://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.1/jquery.min",
"bootstrap": "http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min"
},
shim: {
"bootstrap": ['jquery']
}
};
</script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.8/require.min.js"></script>
<script>
require(['bootstrap'], function () {
});
</script>
</head>
<body>
<div class="alert fade in" style="margin-right:20px;">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Holy guacamole!</strong> Best check yo self, you're not looking too good.
</div>
</body>
</html>
最佳答案
因为 Browser link
在 VS2013 中默认启用。
如果您正在调试您的 Web 应用程序,您可以取消选中“启用浏览器链接”,这将关闭所有 future 请求的“浏览器链接”。
您还可以在 web.config 文件中使用以下应用设置。将应用设置“vs:EnableBrowserLink”设置为“false”。这将禁用浏览器链接。
<appSettings>
<add key="vs:EnableBrowserLink" value="false" />
<!--other settings -->
</appSettings>
关于javascript - RequireJS JQuery 垫片不适用于 VS2013,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18171146/