gpt4 book ai didi

css - 将 Thymeleaf 转换为 <style></style>

转载 作者:技术小花猫 更新时间:2023-10-29 11:17:32 24 4
gpt4 key购买 nike

我将 Polymer 与 Thymeleaf 一起使用,我想在 paper-scroll-header-panel 元素未压缩时设置背景图像。所以,我正在尝试:

paper-scroll-header-panel{
--paper-scroll-header-panel-full-header: {
background-image: url("+ @{(${session.user.coverImagePath})} + ");
};
}

但是 Thymeleaf 没有呈现这段代码,当我访问这个模板时,我得到了原样的代码。那么,如何使用 Thymeleaf 设置此属性?

最佳答案

您必须明确告诉 Thymeleaf 在具有 th:inline 属性的文本中查找表达式,而不是用双方括号将表达式括起来。

<style th:inline="text">
paper-scroll-header-panel{
--paper-scroll-header-panel-full-header: {
background-image: url([[@{(${session.user.coverImagePath})}]]);
};
}
</style>

Thymeleaf 的作者出于性能原因选择了这种方案,因为 Thymeleaf 的模板解析和处理与 JSP 或 Facelets 有很大不同。

关于css - 将 Thymeleaf 转换为 &lt;style&gt;&lt;/style&gt;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32016897/

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