Notice: 函数 WP_Scripts::localize 的调用方法不正确$l10n 参数必须是一个数组。若要将任意数据传递给脚本,请改用 wp_add_inline_script() 函数。 请查阅调试 WordPress来获取更多信息。 (这个消息是在 5.7.0 版本添加的。) in /data/www/appblog/wp-includes/functions.php on line 6131

Thymeleaf字符串拼接

Thymeleaf字符串拼接:用+符号,也可以用|符号

th:text字符串拼接

user.name从后台传来的变量,${user.name}获得变量值。

文本连接

user.name="张三",解析结果为:<span>Welcome,张三</span>

<span th:text="'Welcome,' + ${user.name}">

文字替换

文字替换可以方便的格式化包含变量的字符串,语法为| text substituion demo ${varialble} |

<span th:text="|Welcome, ${user.name}!|">

等效于

<span th:text="'Welcome, ' + ${user.name} + '!'">

文字替换本身可以和与其他表达式联合使用

<span th:text="${onevar} + ' ' + |${twovar}, ${threevar}|">

th:action字符串拼接

user.userId=1,解析结果为:<form action="/user/1"></form>

<form th:action="@{'/user/'+${user.userId}}"></form>
<form th:action="@{/user/{userId}(userId=${user.userId})}"></form>
上一篇 Hexo模板
下一篇 iframe实现Html嵌入Html