gpt4 book ai didi

jquery - 布局页面不加载 css (asp.net mvc)

转载 作者:太空宇宙 更新时间:2023-11-04 12:38:01 25 4
gpt4 key购买 nike

我使用以下包来加载 css 并且它有效:

bundles.Add(new StyleBundle("~/bundles/jqGrid-styles").Include(
"~/Content/themes/base/jquery-ui.css",
"~/Content/jquery.jqGrid/ui.jqgrid.css"));

...

在我的布局页面中这有效:

@Styles.Render("~/bundles/jqGrid-styles")

如果我尝试简单地添加指向页面的链接,那是行不通的。

这根本不起作用:

<link href="~/Content/themes/base/jquery-ui.css" rel="stylesheet" />
<link href="~/Content/jquery.jqGrid/ui.jqgrid.css" rel="stylesheet" />

有人可以通过简单地向页面添加链接来解释我为什么这不起作用吗?文件位于正确的位置。

最佳答案

您需要添加 Url.Content方法:-

<link href="@Url.Content("~/Content/themes/base/jquery-ui.css") rel="stylesheet" />
<link href="@Url.Content("~/Content/jquery.jqGrid/ui.jqgrid.css") rel="stylesheet" />

您需要从应用程序绝对路径中选择文件。

关于jquery - 布局页面不加载 css (asp.net mvc),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27122543/

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