gpt4 book ai didi

javascript - <网络优化 :BundleReference> renders ScriptBundle as css link elements

转载 作者:搜寻专家 更新时间:2023-11-01 04:41:34 26 4
gpt4 key购买 nike

我正在尝试使用新的 .net 4.5 webforms 控件在我的母版页中呈现包。我在我的 BundleConfig.cs 中定义了一个脚本包,如下所示:

bundles.Add(new ScriptBundle("~/bundles/app").Include(
"~/Scripts/underscore.js",
"~/Scripts/backbone.js",
"~/Scripts/app/app.js",
"~/Scripts/app.validator.js",
"~/Scripts/app/views/home.js",
"~/Scripts/app/views/about.js",
"~/Scripts/app/views/contact.js",
"~/Scripts/app/controls/hello.js",
"~/Scripts/app/init.js"));

然后我尝试使用新的 <webopt:BundleReference> 渲染包控制:

<webopt:BundleReference ID="AppBundle" runat="server" Path="~/bundles/app"  />

但是当页面呈现时,输出是<link>标签,而不是标签:

<link href="/Scripts/underscore.js" rel="stylesheet"/>
<link href="/Scripts/backbone.js" rel="stylesheet"/>
<link href="/Scripts/app/app.js" rel="stylesheet"/>
<link href="/Scripts/app/views/home.js" rel="stylesheet"/>
<link href="/Scripts/app/views/about.js" rel="stylesheet"/>
<link href="/Scripts/app/views/contact.js" rel="stylesheet"/>
<link href="/Scripts/app/controls/hello.js" rel="stylesheet"/>
<link href="/Scripts/app/init.js" rel="stylesheet"/>

这个控件是用来渲染样式的吗?还是我做错了什么?如何使用 webopt 控件而不是 <%: Scripts.Render() %> 呈现脚本包语法?

最佳答案

我使用的是 VS2012 和 .Net 4.5。我不使用 webopt 控件。我这样渲染:

<head>
<asp:PlaceHolder runat="server">
<%: Styles.Render("~/Content/MainContentCSS") %>
<%: Scripts.Render("~/bundles/jqueryPlus") %>
</asp:PlaceHolder>
</head>

我的 css 和 js 也在 BundleConfig.vb 中定义为:

bundles.Add(New ScriptBundle("~/bundles/jqueryPlus").Include(
"~/Scripts/modernizr-{version}.js",
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-ui-{version}.js",
"~/ig_ui/js/infragistics.js",
"~/Site.Master.js"))

bundles.Add(New StyleBundle("~/Content/MainContentCSS").Include(
"~/Content/Site.css",
"~/Content/Site-overrides.min.css",
"~/Content/rs-custom-controls.min.css",
"~/ig_ui/css/structure/infragistics.css",
"~/Examiner/Claim.master.min.css"))

并呈现为:

<link href="/Content/Site.css" rel="stylesheet"/>
<link href="/Content/Site-overrides.min.css" rel="stylesheet"/>
<link href="/Content/rs-custom-controls.min.css" rel="stylesheet"/>
<link href="/ig_ui/css/structure/infragistics.css" rel="stylesheet"/>
<link href="/Examiner/Claim.master.min.css" rel="stylesheet"/>
<script src="/Scripts/jquery-2.1.3.js"></script>
<script src="/Scripts/jquery-ui-1.11.2.js"></script>
<script src="/Scripts/modernizr-2.8.3.js"></script>
<script src="/ig_ui/js/infragistics.js"></script>
<script src="/Site.Master.js"></script>

关于javascript - <网络优化 :BundleReference> renders ScriptBundle as css link elements,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22863705/

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