【发布时间】:2021-09-06 02:39:15
【问题描述】:
我有这个js函数
import numberToWordsRu from 'number-to-words-ru';
function convert(number)
{
return numberToWordsRu.convert(number);
}
我想在 th:text 中调用它来传递参数。像这样的:
<p th:text="'This ' + ${param} + ' is ' + convert(${param})">
</p>
是否有可能以及如何正确地做到这一点?
【问题讨论】:
-
这可能工作 th:onclick="'myFunction() 你可以参考stackoverflow.com/questions/26526037/…
-
这可能有效 th:onclick="'myFunction() 你可以参考stackoverflow.com/questions/26526037/…
-
了解 Thymeleaf 在服务器上运行很重要。它从模板生成 HTML,然后将 HTML 发送到显示它的浏览器。到那时,JavaScript 可以开始工作,但 Thymeleaf 将不再做任何事情。
-
这就是我想要的,我想在开始时使用函数更改输入值。
标签: javascript html thymeleaf