gpt4 book ai didi

grails - grails 2.4.0 上的 Assets 标签

转载 作者:行者123 更新时间:2023-12-02 14:07:23 24 4
gpt4 key购买 nike

我在 2.4.0 版本上开始了一个新的 grails 项目。
在这个版本中,grails-app 文件夹中添加了子文件夹asset,以便于访问js、css、图像等。

但是,我无法访问子文件夹,例如,我的文件夹结构如下:
grails-app/assets/stylesheets/fonts/font.css
然后当我使用<asset:stylesheet src="font.css"/> (注意 font.css 放在 stylesheets 文件夹中)

但是当我尝试这个时,没有找到 font.css。

<asset:stylesheet src="/fonts/font.css"/>

请建议另一种使用 Assets 标签访问子文件夹的方法。

最佳答案

不要直接链接到子文件夹。使用application.cssgrails-app/assets/stylesheets .

application.css告诉 Assets 插件包括你的font.css通过添加以下内容:

/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS file within this directory 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 fonts/font.css
*= require self
*/

在您的布局 (GSP) 中使用 application.css像这样。
<asset:stylesheet src="application.css"/>

这将解决您的问题。

关于grails - grails 2.4.0 上的 Assets 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24321211/

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