首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PhotoSwipe,Rails,Coffee根本不工作

PhotoSwipe,Rails,Coffee根本不工作
EN

Stack Overflow用户
提问于 2020-10-19 15:37:16
回答 1查看 81关注 0票数 0

不明白为什么当我试图将PhotoSwipe添加到Rails项目中时,它没有显示任何东西

https://github.com/skakri/photoswipe-rails

  • Step:
  1. 使用了这个gem:的复制手册:https://photoswipe.com/documentation/getting-started.html#init-add-pswp-to-dom
    1. Wrote 'click‘处理程序,但是它没有显示

我写的代码:

代码语言:javascript
复制
<body>
  <!-- some Rails and other stuff -->
  <%= render 'shared/photoswipe' %> 
</body>

end包含从页尾成功添加的div class="pswp“的完整副本。

在单击处理程序上为PhotoSwipe init添加了一些咖啡代码

代码语言:javascript
复制
$ ->
  $PhotoContainer = $('#MainPhoto')
  $PhotoContainer.click ->
    $pswpElement = document.querySelectorAll('.pswp')[0]
    $items = []
    $('.photo-item').each ->
      $Img = $(@)
      $items.push( { src: getUrlFromImg($Img).bigImgUrl, w: 1000, h: 1000 } )

    $options = {
      history: false,
      focus: false,
      index: 0
    }
    $gallery = new PhotoSwipe( $pswpElement, PhotoSwipeUI_Default, $items, $options)
    $gallery.init()

当我单击触发的#MainPhoto容器事件时,$items数组正确地由图像urls和大小填充并调用PhotoSwipe init()函数,但屏幕上没有显示任何内容

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-20 13:19:31

创业板写得不对应该添加

代码语言:javascript
复制
@import "photoswipe/index";
@import "photoswipe/photoswipe";
@import "photoswipe/default-skin/default-skin";

进入application.scss

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64430618

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档