我已经从Bootstrap 3更新到Bootstrap 4,现在Razor View无法正常渲染,如下图所示:
正如您所看到的,所有Bootstrap样式都消失了,导航栏已经消失。 Bootstrap 3很好。
这只是MVC项目附带的标准登录页面,所以我没有添加任何花哨的东西。
我的包如下:
using System.Web;
using System.Web.Optimization;
namespace FoodSnap
{
public class BundleConfig
{
// For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-ui-{version}.js"));
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/site.css",
"~/Content/themes/base/jquery-ui.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")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@*@Html.ActionLink("FoodSnap_TEST", "LogIn", "Account", new { area = "" }, new { @class = "navbar-brand" })*@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
@*<li>@Html.ActionLink("Home", "Index", "Home")</li>*@
@*<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>*@
<li>@Html.ActionLink("Pre-Registration", "Index", "PreRegistration")</li>
<li>@Html.ActionLink("Roles", "Index", "Role")</li>
<li>@Html.ActionLink("FoodSnap", "Index", "FoodSnap")</li>
<li>@Html.ActionLink("Review", "Create", "FoodSnap")</li>
</ul>
@Html.Partial("_LoginPartial")
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - FoodSnap_TEST</p>
</footer>
</div>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
我尝试了很多东西,包括CDN,结果是一样的。有没有人见过这个?
答案 0 :(得分:1)
Bootstrap 4几乎完全重写了Bootstrap 3,意思是:
Bootstrap 3代码都没有与Bootstrap 4兼容。
阅读要迁移的文档: