未捕获的类型错误:r.getClientRects不是函数jquery.min.js:2

63lcw9qa  于 2023-08-04  发布在  jQuery
关注(0)|答案(2)|浏览(239)

您好,我不明白Web控制台中的错误是什么意思。

Uncaught TypeError: r.getClientRects is not a function jquery.min.js:2

字符串
我正在尝试在laravel中构建一个基于我下载的bootstrap主题的自动完成搜索表单。
它的工作,但下拉是不对齐的文本框,我怀疑jQuery,因为这个错误和事实,在一个不同的引导主题,我有,它的工作我有我的脚本链接如下

<link href="http://myurl.com/vendor/bootstrap/css/bootstrap.min.css" 
rel="stylesheet">
<link href="http://myurl.com/vendor/fontawesome-free/css/all.min.css" 
rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Varela+Round" 
rel="stylesheet">
<link href="https://fonts.googleapis.com/css 
rel="stylesheet">
<link href="http://myurl.com/css/grayscale.min.css" rel="stylesheet">
<script src='https://www.google.com/recaptcha/api.js'></script>
<script src="http://myurl.com/vendor/jquery/jquery.min.js"></script>
<script 
src="http://myurl.com/vendor/bootstrap/js/bootstrap.bundle.min.js"> . 
</script>
<script src="http://myurl.com/vendor/jquery- 
easing/jquery.easing.min.js"></script>
<script src="http://myurl.com/js/grayscale.min.js"></script>


我的表格:

<form class="form-inline d-flex">

            <input class="form-control autocomplete_txt input-lg flex-fill mr-0 mr-sm-2 mb-3 mb-sm-0" 
                   type='text' data-type="EmpService" id='EmpService_1' name='EmpService[]' autocomplete="off" placeholder="looking for...">

                       <button type="submit" class="btn btn-primary mx-auto">Search</button>
             <div class="col-xs-4 g-recaptcha" data-sitekey="6Lf9mW4UAAAAACtNJIuXY9VlCZ5kg0Ys7Y3ancH_"></div>   

</form>


我的JavaScript:

$(document).on('focus','.autocomplete_txt',function(){
  type = $(this).data('type');

  if(type =='EmpService' )autoType='EmployeeService'; 


   $(this).autocomplete({
       minLength: 0,
       source: function( request, response ) {
            $.ajax({
                url: "http://spanibox.com/searchajax",
                dataType: "json",
                data: {
                    term : request.term,
                    type : type,
                },
                success: function(data) {
                    var array = $.map(data, function (item) {
                       return {
                           label: item[autoType],
                           value: item[autoType],
                           data : item
                       }
                   });
                    response(array)
                }
            });
       },
       select: function( event, ui ) {
           var data = ui.item.data;           
           id_arr = $(this).attr('id');
           id = id_arr.split("_");
           elementId = id[id.length-1];
           $('#EmpService_'+elementId).val(data.name);

       }
   });

a6b3iqyw

a6b3iqyw1#

这个问题可能是由于使用jQuery 3.1。尝试添加:
第一个月

ha5z0ras

ha5z0ras2#

如果你不想降级jquery,那么我找到了这个修复方法:https://github.com/markdalgleish/stellar.js/pull/147/commits/2051858ab77eaec82abe5b287d740dcfbb3e7605#diff-5e6a197fd748dcc5d0c34558b8ecde5f6c61bccea987386d5f1844cfe3eb2162
如果你只有jquery.stellar.min.js文件,你可以找到并替换这些函数(缩小版):

refresh:function(c){var d=this,e=d._getScrollLeft(),f=d._getScrollTop();c&&c.firstLoad||this._reset(),this._setScrollLeft(0),this._setScrollTop(0),this._setOffsets(),this._findParticles(),this._findBackgrounds(),c&&c.firstLoad&&/WebKit/.test(navigator.userAgent)&&a(b).load(function(){var a=d._getScrollLeft(),b=d._getScrollTop();d._setScrollLeft(a+1),d._setScrollTop(b+1),d._setScrollLeft(a),d._setScrollTop(b)}),this._setScrollLeft(e),this._setScrollTop(f)},_detectViewport:function(){var a=this.$viewportElement.offset(),b=null!==a&&a!==d;this.viewportWidth=this.$viewportElement.width(),this.viewportHeight=this.$viewportElement.height(),this.viewportOffsetTop=b?a.top:0,this.viewportOffsetLeft=b?a.left:0},

字符串
对于这些:

refresh: function (c) {
        var d = this,
            e = d._getScrollLeft(),
            f = d._getScrollTop();
        (c && c.firstLoad) || this._reset(),
            this._setScrollLeft(0),
            this._setScrollTop(0),
            this._setOffsets(),
            this._findParticles(),
            this._findBackgrounds(),
            c &&
                c.firstLoad &&
                /WebKit/.test(navigator.userAgent) &&
                a(b).on("load", function () {
                    var a = d._getScrollLeft(),
                        b = d._getScrollTop();
                    d._setScrollLeft(a + 1),
                        d._setScrollTop(b + 1),
                        d._setScrollLeft(a),
                        d._setScrollTop(b);
                }),
            this._setScrollLeft(e),
            this._setScrollTop(f);
    },
    _detectViewport: function () {
        var a =
                this.$viewportElement[0] !== window
                    ? this.$viewportElement.offset()
                    : { top: 0, left: 0 },
            b = null !== a && a !== d;
        (this.viewportWidth = this.$viewportElement.width()),
            (this.viewportHeight = this.$viewportElement.height()),
            (this.viewportOffsetTop = b ? a.top : 0),
            (this.viewportOffsetLeft = b ? a.left : 0);
    },

相关问题