0

このコード行を Coffeescript でどのように記述できますか? ありがとう

    window.scrollY >= origOffsetY ? navbar.classList.add('navbar-fixed-top') : 
                                    navbar.classList.remove('navbar-fixed-top');

これを試してみましたが、うまくいきません。

if window.scrollY >= origOffsetY then navbar.classList.add('navbar-fixed-top') else navbar.classList.remove('navbar-fixed-top')
4

1 に答える 1

0

あなたのcoffeescriptは次のようにコンパイルされます:

if (window.scrollY >= origOffsetY) {
  navbar.classList.add('navbar-fixed-top');
} else {
  navbar.classList.remove('navbar-fixed-top');
}

これは私にはかなり問題ないようです。

于 2013-03-22T16:53:01.450 に答える