• #19 楼 @JeremyLi 解决了,只要在相应的 apples.js.coffee 里定义的函数加前缀 window.就可以声明全局变量,再在另外一个文件 init.js.coffee 里定义 window.FruitsSite,调用 apples.js.coffee 里的函数时加上 window.前缀就可以。

  • Rails 4 中 coffee 的问题 at 2014年04月07日

    #6 楼 @Rei 太感谢了!可以了!

  • Rails 4 中 coffee 的问题 at 2014年04月07日

    #3 楼 @5swords 新手求救,能再说的详细点吗?能提供代码最好,多谢。 我现在主要的问题是在 after_render.js.coffee 里面看不到定义在 devices.js.coffee 里的函数 f1()。

  • 我按照 solution 3 进行了测试,当在 apples.js.coffee 里定义 Window.FruitsSite = apples: index: init: () -> console.log("init apples index page") return

    然后再 oranges.js.coffee 里定义 Window.FruitsSite = oranges: index: init: () -> console.log("init oranges index page") return 之后调用的时候,oranges 里 Window.FruitsSite 的值会覆盖 apples 里的值啊,导致调用 apples 的 index 函数时没反应啊,该如何解决啊?