高级thymeleaf(组件嵌套)
1.组件嵌套
1.需要提取的组件加上 th:fragment="组件名"
<nav class="col-md-2 d-none d-md-block bg-light sidebar" th:fragment="sidebar"> ... </nav>
2.使用组件的地方加上 th:replace="~{组件地址::组件名}"
<div th:replace="~{dashboard::sidebar}"></div>
2.thymeleaf是一个是一个动态语言,可以在语句中嵌套表达式
在class中添加if
<a th:class="${active=='list.html'?'nav-link active':'nav-link'}" th:href="@{/emps}"> 员工管理 </a>
....
浙公网安备 33010602011771号