lazy:对于Lazyload图像gem来说,它会破坏Ruby on Rails 5的图像

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

我正在尝试为我的图像重型网站安装https://github.com/jassa/lazyload-rails

添加所需的lazy:true时,图像不显示

Ruby on Rails 5的语法需要不同吗?

<%= link_to image_tag(post.image_url.to_s, lazy: true), post_path(post), remote: true %>

谢谢


的Gemfile

gem "lazyload-rails"

application.html.erb

<script>
   $("img").lazyload();
</script>
ruby-on-rails image rubygems ruby-on-rails-5 lazyload
1个回答
-1
投票

你必须下载jQuery Lazy Load Plugin脚本并将其放在vendor/assets/javascripts

© www.soinside.com 2019 - 2024. All rights reserved.