【问题标题】:unexpected indentation in coffee rails?咖啡导轨上出现意外的压痕?
【发布时间】:2018-02-17 18:33:02
【问题描述】:

我正在尝试使用 will_paginate 和咖啡在 Rails 中进行无限滚动,在我编写代码后它给了我这个错误?

我使用 ATOM ATOM 作为我的 IDE .......

Showing C:/Users/more/Desktop/railsapp/app/views/layouts/application.html.erb where line #6 raised:

    SyntaxError: [stdin]:7:1: unexpected indentation

我的帖子.咖啡

# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
  if $('#infinite-scrolling').size() > 0
    $(window).on 'scroll', ->
      more_posts_url = $('.pagination .next_page a').attr('href')
        if more_posts_url && $(window).scrollTop() > $(document).height() - $(window).height() - 60
            $('.pagination').html('<p> loading <p>')
            $.getScript more_posts_url
        return
      return

【问题讨论】:

    标签: jquery ruby-on-rails coffeescript


    【解决方案1】:

    more_posts_url 变量后面多了一个缩进块:

    if $('#infinite-scrolling').size() > 0
      $(window).on 'scroll', ->
        more_posts_url = $('.pagination .next_page a').attr('href')
        if more_posts_url && $(window).scrollTop() > $(document).height() - $(window).height() - 60
          $('.pagination').html('<p> loading <p>')
          $.getScript more_posts_url
        return
      return
    

    【讨论】:

      猜你喜欢
      • 2012-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-15
      • 2015-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多