gpt4 book ai didi

javascript - 导入 javascript 库可以在 chrome 中运行,但不能在 IE 中运行

转载 作者:行者123 更新时间:2023-12-03 09:00:10 25 4
gpt4 key购买 nike

我正在使用 ASP.NET MVC 5,我正在尝试导入一些 javascript 库,如 jquery、bootstrap.js 等。它在 Chrome 中运行良好,但在 IE 11 中运行不佳。

有人能看到我缺少什么吗?

捆绑配置:

public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-2.1.4.js",
"~/Scripts/jquery-2.1.4.min.js",
"~/Scripts/EventReader.js",
"~/Scripts/jquery.floatThead.js",
"~/Scripts/jquery.floatThead.min.js",
"~/Scripts/jquery.unobtrusive-ajax.js"));

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));

// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));

bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js"));

bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/bootstrap.min.css",
"~/Content/EventReader.css"));
}

_布局:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Styles.Render("~/Content/bootstrap")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")


</head>
<body>
<div class="container body-content">
@RenderBody()
@RenderSection("scripts", required: false)
</div>

</body>
</html>

我的 View (索引):

@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}

<html>
<head>
<meta name="viewport" content="width=device-width"/>
<title>Index</title>

</head>
<body>
</body>

在 IE11 中,我收到以下错误:

Object doesn't support property or method 'addEventListener' (jquery-2.1.4.js).
Object doesn't support property or method 'addEventListener' (jquery-2.1.4.min.js)
Bootstrap's JavaScript requires jQuery (bootstrap.js)

最佳答案

添加 <meta http-equiv="X-UA-Compatible" content="IE=Edge">在文档头部部分强制 IE 使用最新 IE 版本的标准进行渲染。

关于javascript - 导入 javascript 库可以在 chrome 中运行,但不能在 IE 中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32328331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com