gpt4 book ai didi

asp.net - 进度条不是一个函数

转载 作者:行者123 更新时间:2023-12-02 02:47:48 29 4
gpt4 key购买 nike

在带有 Bootstrap 进度条的页面上,我收到错误:

$(...).progressbar is not a function

正如我所见,此错误似乎使我的其余脚本崩溃:

  1. Typeahead 无法在同一页面上运行我收到以下错误:

Bloodhound is not defined

  • Bootstrap 选择不起作用
  • 网页模板不起作用
  • 有趣的是,如果我的 enable.optimization 设置为 false,我的其余脚本不会崩溃。

    下面是我的进度条的 HTMLjavascript:

    function UpdateProgress(totalRecords, recordsProcessed, message) {

    var pct = recordsProcessed / totalRecords * 100;
    $('.progress-bar').css('width', pct + '%').attr('aria-valuenow', pct);

    $('#message').text(message);

    var msg = Math.round(pct, 2) + '% Complete';
    $('.progText').text(msg);

    if (pct > 0) {
    $('#progressRow').show();
    }

    if (pct == 100) {
    $('#progressRow').hide();
    }
    }


    <div id="progressRow" class="row" >
    <div class="form-group">
    <div class="col-md-offset-2 col-sm-offset-2 col-md-10 col-sm-10 col-xs-12">
    <label id="message"></label>
    <div class="progress" style="height: 30px">
    <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
    <span class="progText"></span>
    </div>
    </div>
    </div>
    </div>
    </div>

    下面是我的bundleConfig 文件:

     bundles.Add(new ScriptBundle("~/Scripts/jquery").Include(
    "~/Scripts/jquery.min.js"
    ));

    bundles.Add(new StyleBundle("~/Content/core").Include(
    "~/Content/bootstrap.min.css",
    "~/Content/animate.min.css",
    "~/Content/custom.min.css",
    "~/Content/font-awesome.min.css",
    "~/Content/green.css",
    "~/Content/outline.button.css",
    "~/Content/bootstrap-datepicker.min.css",
    "~/Content/Pagination.css",
    "~/Content/animation.css",
    "~/Content/jBox.css",
    "~/Content/SpinnerOverLay.css",
    "~/Content/bootstrap-select.min.css",
    "~/Content/typeahead.css",
    "~/Content/icheck/square/green.css",
    "~/Content/icheck/green.css"
    ));

    bundles.Add(new StyleBundle("~/Content/login").Include(
    "~/Content/bootstrap.min.css",
    "~/Content/font-awesome.min.css",
    "~/Content/animate.min.css",
    "~/Content/custom.min.css",
    "~/Content/green.css",
    "~/Content/animation.css",
    "~/Content/jBox.css",
    "~/Content/SpinnerOverLay.css"

    ));

    bundles.Add(new ScriptBundle("~/Scripts/core").Include(
    "~/Scripts/bootstrap.min.js",
    "~/Scripts/custom.min.js",
    "~/Scripts/nprogress.min.js",
    "~/Scripts/bootstrap-datepicker.min.js",
    "~/Scripts/jquery.bpopup.min.js",
    "~/Scripts/bootstrap-select.min.js",
    "~/Scripts/typeahead.min.js",
    "~/Scripts/icheck/icheck.min.js"
    ));

    bundles.Add(new ScriptBundle("~/Scripts/login").Include(
    "~/Scripts/jquery.bpopup.min.js"
    ));

    bundles.Add(new ScriptBundle("~/Scripts/SignalR").Include(
    "~/Scripts/jquery.signalR-2.2.0.min.js"
    ));
    BundleTable.EnableOptimizations = false;

    这就是 masterPage 中引用 cssjs 文件的方式:

    <head runat="server">
    <title>Stores</title>
    <%: System.Web.Optimization.Styles.Render("~/Content/core") %>

    <%: System.Web.Optimization.Scripts.Render("~/Scripts/jquery") %>

        <%:System.Web.Optimization.Scripts.Render("~/Scripts/core") %>
    <script src="/Scripts/notify/pnotify.buttons.min.js"></script>
    <script src="/Scripts/notify/pnotify.core.min.js"></script>
    <script src="/Scripts/notify/pnotify.nonblock.min.js"></script>

    <script src="/Scripts/init.controls.js"></script>
    <script src="/Scripts/showDisplayModalSetup.js"></script>
    <script src="/Scripts/client.validation.js"></script>

    最佳答案

    我认为它工作正常。

    您应该正确包含库:

    第一: Jquery.js

    第二: Bootstrap.js

    如下图

    function UpdateProgress(totalRecords, recordsProcessed, message) {

    var pct = recordsProcessed / totalRecords * 100;
    $('.progress-bar').css('width', pct + '%').attr('aria-valuenow', pct);

    $('#message').text(message);

    var msg = Math.round(pct, 2) + '% Complete';
    $('.progText').text(msg);

    if (pct > 0) {
    $('#progressRow').show();
    }

    if (pct == 100) {
    $('#progressRow').hide();
    }
    }

    UpdateProgress(100, 99, 'Loading')
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>

    <div id="progressRow" class="row" >
    <div class="form-group">
    <div class="col-md-offset-2 col-sm-offset-2 col-md-10 col-sm-10 col-xs-12">
    <label id="message"></label>
    <div class="progress" style="height: 30px">
    <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
    <span class="progText"></span>
    </div>
    </div>
    </div>
    </div>
    </div>

    如果我错过了什么,请告诉我。

    关于asp.net - 进度条不是一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38672528/

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