gpt4 book ai didi

css - 无法访问子元素中的样式表

转载 作者:行者123 更新时间:2023-11-28 02:43:49 25 4
gpt4 key购买 nike

我(终于)在 Play Framework 中设置了一个子元素,但无法访问样式表(用于子元素)。我有以下内容:

元素结构

   main-project
_build.sbt
_app
_controllers
_models
_views
_conf
_application.conf
_routes
_modules
_admin
_build.sbt
_app
_controllers
_admin
_Assets
_HomeController
_models
_views
_admin
_aMain.scala.html
_assets
_less
_admin.less
_conf
_admin.routes
_project
_build.properties
_plugins.sbt

admin.routes

   GET /                  controllers.admin.HomeController.index

GET /assets/*file controllers.admin.Assets.at(path="/public/lib/admin", file)

aMain.scala.html

@(title: String)

<!DOCTYPE html>
<html lang="en">
<head>
<title>@title</title>
<link rel="stylesheet" media="screen" href="@admin.routes.Assets.at("less/admin.less")">
<link rel="shortcut icon" type="image/png" href="@admin.routes.Assets.at("images/favicon.png")">
<script src="@admin.routes.Assets.at("javascripts/hello.js")" type="text/javascript"></script>
</head>
<body>
@* And here's where we render the `Html` object containing
* the page content. *@


<div class="blue-italic">@title</div>

</body>
</html>

因此页面加载成功但样式表未加载。我什至将路径和文件名设置为唯一的,以避免任何潜在的冲突。任何人都可以看到这里出了什么问题吗?谢谢

最佳答案

你应该试试这个(只使用唯一的 Assets Controller ):

GET/assets/*file controllers.Assets.at(path="/public/lib/admin", file)

来自 scala play 文档:

Note: Resources are served from a unique classloader, and thus resource path must be relative from project classpath root. Subprojects resources are generated in target/web/public/main/lib/{module-name}, so the resources are accessible from /public/lib/{module-name} when using play.api.Application#resources(uri) method, which is what the Assets.at method does.

关于css - 无法访问子元素中的样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47022643/

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