新手问题 关于如何组织 coffee 文件

dccmmtop · August 02, 2017 · Last by dccmmtop replied at August 03, 2017 · 1307 hits

我想要在 view/wechat/nodes/下为某个页面使用 js,我在 assets/javascript/如何建 coffee 文件呢?

难道是 /assets/javascript/wechat/nodes.coffee 吗??

  1. 如果要写页面特定的 js,可以用 <script></script> 内嵌在页面。
  2. 如果可以写成非侵入式,可以在 /assets/javascript 下新建任意一个 coffee 文件,默认都会被打包到 application.js 中。顶楼的路径是符合惯例的。
  3. 如果想要独立打包,独立引用,就要关掉默认的打包行为,然后设定独立的打包目标。你需要完整了解 Assets Pipeline 的行为 https://ruby-china.github.io/rails-guides/asset_pipeline.html
Reply to Rei

谢谢

You need to Sign in before reply, if you don't have an account, please Sign up first.