[英]ruby on rails and assets
我剛剛啟動了我的第一個ruby應用程序。
我將應用程序所需的css和js文件復制到資產文件夾,當我運行該應用程序時,所有css和js都加載到頁面中,我不希望那樣
我的看法很簡單
hello
我的application.css僅是注釋
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
為什么要加載所有資產? 我可以“禁用”此功能嗎?
我要做的就是以特定順序定義視圖文件中所需的文件(css,js),並僅加載特定頁面所需的js。
如果您編寫* = require樹,這意味着將添加javascript文件夾上的所有js,並且對css也是如此。 因此刪除這些行。 同時,您可以對應用程序使用資產管理器來管理您的資產(使其在特定頁面上顯示)以進行標准資產管理。我建議您檢查http://railscasts.com/episodes/279-understanding-the -asset-pipeline?view = asciicast和https://rails-assets.org/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.