在js模板中使用thymeleaf语法
原文链接:https://blog.csdn.net/weixin_43670802/article/details/119574286
在js模板中使用thymeleaf语法
问题描述
今天在学习thymeleaf时遇到一个问题,就是如果正常在JS中写thymeleaf语法会报错。
解决方案
在script标签中通过th:inline="javascript"来声明这是要特殊处理的js脚本
使用格式:/*[[Thymeleaf表达式]]*/
示例
<script th:inline="javascript">
let aa = /*[[${user}]]*/ ;
</script>
------------------------------------------------------------------------------
<form class="form-horizontal m" id="form-worker-edit" th:object="${appWorker}">
var supperlierId0=[[${appWorker.supperlierId0}]];
用空常来坐坐
https://www.cnblogs.com/alexgl2008/

浙公网安备 33010602011771号