JQuery匹配高度不适用于Rails 5.2

问题描述 投票:0回答:1

尝试在我的Rails应用程序上安装Jquery Match Height后,我收到以下错误。

enter image description here

我尝试过使用Match Height Gem,只需将整个脚本复制粘贴到我的application.js中,并且(目前)在我的application.html.erb上包含CDN:

 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.matchHeight/0.7.2/jquery.matchHeight.js" type="text/javascript"></script>

无论如何都会产生相同的错误。我安装了这些与jquery相关的gem:

gem 'jquery-rails'
gem 'jquery-ui-rails'

以下是我尝试使用Match Height的方法:

<script>
  $(document).ready(function() {
    $('.card-img-top').matchHeight();
    $('.card-title').matchHeight();
    $('.card-text').matchHeight();
    $('.card-footer').matchHeight();
  });
</script>

谁能看到我做错了什么?

jquery ruby-on-rails ruby-on-rails-5
1个回答
0
投票

如果你使用宝石jquery-matchheight-rails,不需要CDN包括

将以下内容添加到JavaScript清单文件中:(application.js)

//= require jquery.matchHeight
© www.soinside.com 2019 - 2024. All rights reserved.