未捕获的TypeError:$(...)。steps不是函数

时间:2019-06-12 10:53:47

标签: javascript jquery html laravel jquery-steps

所以我在引导程序模板中看到了非常漂亮的表单,我想在项目中使用它们。

我将所有我认为需要导入的必需文件放置在代码的底部,这些必需文件位于正确的目录中,例如jquery步骤:C:\xampp\htdocs\rps\public\files\bower_components\jquery.steps\js\jquery.steps.js

'initialize-steps.js':

$("#practitioner-form").steps({
    headerTag: "h3",
    bodyTag: "fieldset",
    transitionEffect: "slideLeft",
    enablePagination: true,
    autoFocus: true,
    onFinished: function (event, currentIndex)
    {
        alert("Practitioner Added!");
    }
});

我的具有多种格式(...)的HTML文件被跳过了一部分:

<div class="card-block">
        <div class="row">
            <div class="col-md-12">
                <div id="practitioner-form">
                    <form method="post" id="practitioner-form" action="#">
                        <h3>Practitioner</h3>
                        <fieldset>
                            <legend>Practitioner Information</legend>
                            <div class="form-group row">
                                <div class="col-lg-12">
                                    <label for="effective_date" class="block">{{trans('personalData.effectiveDate')}}</label>
                                </div>
                                <div class="col-lg-12">
                                    <input id="effective_date" name="effectiveDate" type="date" class="form-control required">
                                </div>
                            </div>

(...)


<link rel="stylesheet" type="text/css" href="/files/bower_components/jquery.steps/css/jquery.steps.css">
<!-- Required Jquery -->
<script src="/files/js/views/person/initialize-steps.js"></script>
<script src="/files/bower_components/jquery/js/jquery.min.js"></script>
<script src="/files/bower_components/jquery-ui/js/jquery-ui.min.js"></script>
<script src="/files/bower_components/popper.js/js/popper.min.js"></script>
<script src="/files/bower_components/bootstrap/js/bootstrap.min.js"></script>
<!--Forms - Wizard js-->
<script src="/files/bower_components/jquery.cookie/js/jquery.cookie.js"></script>
<script src="/files/bower_components/jquery.steps/js/jquery.steps.js"></script>
<script src="/files/bower_components/jquery-validation/js/jquery.validate.js"></script>

<script src="/files/js/modules/practitionerCompetence.js"></script>

在尝试加载页面时仍然出现错误:Uncaught TypeError: $(...).steps is not a function任何人都知道如何修复它?

2 个答案:

答案 0 :(得分:2)

像这样订购js,将脚本放在最后

<script src="/files/bower_components/jquery/js/jquery.min.js"></script>
<script src="/files/bower_components/jquery-ui/js/jquery-ui.min.js"></script>
<script src="/files/bower_components/popper.js/js/popper.min.js"></script>
<script src="/files/bower_components/bootstrap/js/bootstrap.min.js"></script>
<!--Forms - Wizard js-->
<script src="/files/bower_components/jquery.cookie/js/jquery.cookie.js"></script>
<script src="/files/bower_components/jquery.steps/js/jquery.steps.js"></script>
<script src="/files/bower_components/jquery-validation/js/jquery.validate.js"></script>

<script src="/files/js/modules/practitionerCompetence.js"></script>
<script src="/files/js/views/person/initialize-steps.js"></script>

答案 1 :(得分:1)

在您的jquery.steps.js之后加载

initialize-steps.js

<script src="/files/js/views/person/initialize-steps.js"></script>
....
<script src="/files/bower_components/jquery.steps/js/jquery.steps.js"></script>

您需要在其后 加载initialize-steps.js

<script src="/files/bower_components/jquery.steps/js/jquery.steps.js"></script>
<script src="/files/js/views/person/initialize-steps.js"></script>
....