If statement 咖啡脚本if/else问题
如何用Coffeescript编写这行代码?谢谢If statement 咖啡脚本if/else问题,if-statement,coffeescript,If Statement,Coffeescript,如何用Coffeescript编写这行代码?谢谢 window.scrollY >= origOffsetY ? navbar.classList.add('navbar-fixed-top') : navbar.classList.remove('navbar-fixed-top'); 我试过了,但没用 if window.scrollY >= origOffsetY then navbar.cla
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')
您的咖啡脚本编译为:
if (window.scrollY >= origOffsetY) {
navbar.classList.add('navbar-fixed-top');
} else {
navbar.classList.remove('navbar-fixed-top');
}
这对我来说似乎很好。对我很有用(你提供的CoffeeScript编译成了你提供的JS)。好的,谢谢,也许是我的编译器。