ASP.NET MVC 5无法呈现jQuery UI CSS包

前端之家收集整理的这篇文章主要介绍了ASP.NET MVC 5无法呈现jQuery UI CSS包前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在我的项目中包含jQuery UI CSS主题包.我在〜/ Content / themes目录中有所有必需的文件,并按如下方式设置我的BundleConfig.cs:
public class BundleConfig
{
    // For more information on bundling,visit http://go.microsoft.com/fwlink/?LinkId=301862
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
        "~/Scripts/jquery-ui-{version}.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/site.css"));

        bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
          "~/Content/themes/base/jquery.ui.core.css","~/Content/themes/base/jquery.ui.resizable.css","~/Content/themes/base/jquery.ui.selectable.css","~/Content/themes/base/jquery.ui.accordion.css","~/Content/themes/base/jquery.ui.autocomplete.css","~/Content/themes/base/jquery.ui.button.css","~/Content/themes/base/jquery.ui.dialog.css","~/Content/themes/base/jquery.ui.slider.css","~/Content/themes/base/jquery.ui.tabs.css","~/Content/themes/base/jquery.ui.datepicker.css","~/Content/themes/base/jquery.ui.progressbar.css","~/Content/themes/base/jquery.ui.theme.css"));            
    }
}

我的_Layout.cshtml有以下< head>:

<head>
    <Meta charset="utf-8" />
    <Meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>@ViewBag.Title</title>
    <link href="//fonts.googleapis.com/css?family=Open+Sans:300,400" rel="stylesheet" type="text/css">
    @Styles.Render("~/Content/themes/base/css","~/Content/css","~/Content/datepicker3.css")
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryui")
    @Scripts.Render("~/bundles/bootstrap")
    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/Content/bootstrap-datepicker.js")
    @RenderSection("head",required: false)
    <link rel="icon" href="@Url.Content("~/Content/favicon.ico")" />
</head>

但是,这是发出的HTML(注意缺少jQuery CSS主题):

<head>
    <Meta charset="utf-8" />
    <Meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title></title>
    <link href="//fonts.googleapis.com/css?family=Open+Sans:300,400" rel="stylesheet" type="text/css">
    <link href="/PackageManager/Content/bootstrap.css" rel="stylesheet"/>
    <link href="/PackageManager/Content/site.css" rel="stylesheet"/>
    <link href="/PackageManager/Content/datepicker3.css" rel="stylesheet"/>
    <script src="/PackageManager/Scripts/jquery-1.10.2.js"></script>
    <script src="/PackageManager/Scripts/jquery-ui-1.11.3.js"></script>
    <script src="/PackageManager/Scripts/bootstrap.js"></script>
    <script src="/PackageManager/Scripts/respond.js"></script>
    <script src="/PackageManager/Scripts/modernizr-2.6.2.js"></script>
    <script src="/PackageManager/Content/bootstrap-datepicker.js"></script>    
    <link rel="icon" href="/PackageManager/Content/favicon.ico" />
</head>

这是我的解决方案结构:

我错过了什么?

解决方法

除非我遗漏了某些内容,否则看起来你的文件都没有以jquery.ui为前缀,但在你的BundleConfig中它们是.

例如,您在BundleConfig中使用jquery.ui.core.css,但解决方案资源管理器中的文件名为core.css.

原文链接:https://www.f2er.com/aspnet/248274.html

猜你在找的asp.Net相关文章