簡體   English   中英

Rails controller.js.coffee沒有顯示

[英]Rails controller.js.coffee not showing up

我剛開始使用Rails。

在資產javascript內部,有一個文件(welcome.js.coffee)內容為

# 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/

我把這個功能放在下面

$(document).ready ->
    alert "Hello World"

如果我放了application.js文件,

//= require welcome

顯示警報,否則顯示。

我正在跳過某些內容,或者即使welcome.js.coffee文件說該邏輯將自動在application.js中可用,我仍然必須手動要求該文件嗎?

您的application.js應該列出

//= require_tree .

作為其中的一行,這需要該文件所在目錄樹中的所有其他文件。如果缺少或需要此行,則必須將其添加回去,否則就需要專門的文件(與welcome )上班。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM