gpt4 book ai didi

javascript - 在 RAILS 应用程序中使用 javascript

转载 作者:行者123 更新时间:2023-12-02 18:56:02 25 4
gpt4 key购买 nike

Rails 3.2.6

据我了解,通过将所有 javascript 放在/app/assets/javascripts 中,应用程序模块就可以访问它们。我正在遵循教程,并在 application.html.erb 的末尾添加了以下行:

<%= javascript_include_tag "application" %>

这是多余的,还是有将其包含在 application.html.erb 末尾的目的?

最佳答案

默认情况下, Assets 不包含在您的 View 中。这就是为什么你必须在布局文件中使用 javascript_include_tag, stylesheet_link_tag 。至于为什么要加在最后——提高页面加载时间。 more about it here

关于javascript - 在 RAILS 应用程序中使用 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15347023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com