thymeleaf之from相关
程序员文章站
2022-05-01 23:13:14
...
动态加载下拉框并设置选中
<select name="interest" lay-filter="aihao" id="gameMapUrl">
<option value=""></option>
<option th:each="mapList : ${mapLists}" th:value="${mapList.mapUrl}" th:text="${mapList.mapInfo}" th:selected="${mapList.mapUrl eq game.gameMapUrl}"></option>
</select>
单选按钮设置选中
<input type="radio" name="gameType" value="0" title="个人游戏" th:field="*{game.gameType}">
<input type="radio" name="gameType" value="1" title="团队游戏" th:field="*{game.gameType}">
js中使用thymeleaf变量
<script type="text/javascript" th:inline="javascript">
let people_sum = [[${game.gameSumPeople}]] ? [[${game.gameSumPeople}]] : 0;
let team_sum = [[${game.gameSumTeam}]] ? [[${game.gameSumTeam}]] : 0;
</script>
设置dom中的data-id这类属性
<div class="operator_btn">
<button class="layui-btn layui-btn-warm layui-btn-sm game_edit_btn" th:attr="data-id=${gameList.gameId}">编辑</button>
<button class="layui-btn layui-btn-sm game_del_btn" th:attr="data-id=${gameList.gameId}">删除</button>
</div>
图片加载失败后的处理
<img th:src="${gameList.gamePic}" alt="" class="game_pic" th:onerror="'this.src=\''[email protected]{/statics/images/backgroup.jpg}+'\''">
推荐阅读
-
JDK源码分析(10)之 Hashtable 相关
-
MySQL 5.7 学习心得之安全相关特性
-
Android编程开发之EditText中不输入特定字符会显示相关提示信息的方法
-
Android编程开发之EditText中不输入特定字符会显示相关提示信息的方法
-
Intellij IDEA 2017新特性之Spring Boot相关特征介绍
-
android开发之camera相关功能
-
突袭HTML5之Javascript API扩展1—Web Worker异步执行及相关概述
-
HTML5之SVG 2D入门8—文档结构及相关元素总结
-
iOS开发之APP相关
-
Android开发笔记之:深入理解Cursor相关的性能问题