首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用Bootstrap-Select时,Bootstrap下拉菜单需要popperJ

使用Bootstrap-Select时,Bootstrap下拉菜单需要popperJ
EN

Stack Overflow用户
提问于 2019-07-28 21:06:05
回答 1查看 185关注 0票数 0

我正在尝试将bootstrap-select导入到我的Webforms应用程序中,但是当我将CSS和JS文件添加到项目中时,下拉菜单不能正确加载。如何在不出现标题错误的情况下将此包添加到我的项目中?它正确地应用了CSS,并且没有任何问题。唯一不起作用的是脚本部分。

我在C#中使用了Visual Studio19开发的webform应用程序模板。

引导版本:4.3.1jQuery版本: 3.4.1 PopperJS版本: 1.14.0

引导-选择版本: 1.13.9

我已经尝试过不使用CDN导入它,但是在本地下载和添加文件,这也不起作用。

代码语言:javascript
运行
复制
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title><%: Page.Title %> - Mi aplicación ASP.NET</title>

    <asp:PlaceHolder runat="server">
        <%: Scripts.Render("~/bundles/modernizr") %>
    </asp:PlaceHolder>

    <webopt:BundleReference runat="server" Path="~/Content/css" />
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/css/bootstrap-select.min.css">

    <link href="Content/bubbly_button.css" rel="stylesheet" />
</head>

在使用bootstrap-select之前,将按照应导入脚本的顺序加载所需的脚本。:

代码语言:javascript
运行
复制
<body id="top">
    <form runat="server">
        <asp:ScriptManager runat="server">
            <Scripts>
                <%--To learn more about bundling scripts in ScriptManager see https://go.microsoft.com/fwlink/?LinkID=301884 --%>
                <%--Framework Scripts--%>
                <asp:ScriptReference Name="MsAjaxBundle" />
                <asp:ScriptReference Name="jquery" />
                <asp:ScriptReference Name="bootstrap" />
                <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
                <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
                <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
                <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
                <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
                <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
                <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
                <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
                <asp:ScriptReference Name="WebFormsBundle" />
                <%--Site Scripts--%>
            </Scripts>
        </asp:ScriptManager>
        <nav class="navbar navbar-inverse bg-dark">
            <div class="container">
                <a class="navbar-brand mb-0 h1" runat="server" href="~/">ECEG Migration</a>
            </div>
        </nav>
        <div class="container body-content">
            <asp:ContentPlaceHolder ID="MainContent" runat="server">
            </asp:ContentPlaceHolder>
            <hr />
            <div class="top-button bubbly-button custom-fab">
                <i class="fas fa-chevron-up"></i>
            </div>
            <footer>
                <p>&copy; <%: DateTime.Now.Year %> - ECEG_Migration</p>
            </footer>
        </div>
    </form>
    <script src="https://kit.fontawesome.com/1ba00c8269.js"></script>

    <!-- Latest compiled and minified JavaScript -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/js/bootstrap-select.min.js"></script>

    <script src="Scripts/myScripts.js"></script>
</body>

在一个占位符中使用下拉列表

代码语言:javascript
运行
复制
<asp:DropDownList ID="dropdown_year" runat="server" CssClass="form-control m-lateral selectpicker"
                    OnSelectedIndexChanged="dropdown_year_SelectedIndexChanged"
                    AutoPostBack="true" AppendDataBoundItems="true">
                    <asp:ListItem Text="All years" Value="All" Selected="True"></asp:ListItem>
                </asp:DropDownList>

我认为我做了正确的事情,导入了它,但下拉菜单不起作用。

EN

回答 1

Stack Overflow用户

发布于 2019-11-27 22:54:11

您需要在引导之前导入popperjs 才能正常工作:

代码语言:javascript
运行
复制
https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.15.0/umd/popper.js

或跟随您的包导入

代码语言:javascript
运行
复制
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="popper.js" Assembly="System.Web" Path="~/Scripts/Popper/popper.js" />
<asp:ScriptReference Name="bootstrap" />
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57241189

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档