0

我正在使用ASP.NET MVC 5,我試圖導入一些JavaScript庫作爲jquery,bootstrap.js和更多。它在Chrome中工作正常,但不在IE 11中。導入javascript庫工程在鉻但不IE瀏覽器

任何人都可以看到我所缺少的東西嗎?

BundleConfig:

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")); 
    } 

_layout:

<!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> 

我的視圖(指數):

@{ 
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) 
+0

@RenderBody()從您的視圖(Index.cshtml)獲取內容,因此不需要在視圖中聲明html,標題,元標記和正文標記。只需聲明內容。 – Dandy

+0

@Dandy謝謝,但它沒有幫助 – MrProgram

+0

當你在IE11中查看源代碼時,你會得到什麼?你在html源代碼中看到腳本標記嗎? – Dandy

回答

1

在文檔頭部分 中添加 <meta http-equiv="X-UA-Compatible" content="IE=Edge">強制IE使用最新IE版本的標準進行渲染。

相關問題