ASP.NET MVC 5不渲染jQuery UI的CSS包 [英] ASP.NET MVC 5 not rendering jQuery UI CSS bundle

查看:162
本文介绍了ASP.NET MVC 5不渲染jQuery UI的CSS包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想包括我的项目中jQuery UI的CSS的主题包。我在我的〜/内容/主题目录中所有必需的文件,并成立了我的 BundleConfig.cs 如下

I am trying to include the jQuery UI CSS theme bundle in my project. I have all the required files in my ~/Content/themes directory, and set up my BundleConfig.cs as follows:

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主题):

However, this is the HTML that's emitted (note the absent jQuery CSS theme):

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

下面是我的解决方案结构:

Here's my solution structure:

我是什么失踪?

推荐答案

除非我失去了一些东西,它看起来像关你的文件是$ P $与pfixed jquery.ui。,而在 BundleConfig 他们。

Unless I'm missing something, it looks like none of your files are prefixed with jquery.ui., but in your BundleConfig they are.

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

For example, you're using jquery.ui.core.css in BundleConfig, but the file in your Solution Explorer is named core.css.

这篇关于ASP.NET MVC 5不渲染jQuery UI的CSS包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆