创建通用文件commons

注意:commons和所有要用thymeleaf的html文件都应该设置引用:
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
提取导航栏
1.找到导航栏所在代码块
<header class="app-header fixed-top">
往往导航栏会以top、side、bottom命名。
2.把导航栏的前端代码块移入commons并命名
<header class="app-header fixed-top" th:fragment="topbar">
<div id="app-sidepanel" class="app-sidepanel" th:fragment="sidebar">
<div class="app-bottom " th:fragment="bottombar">
th:fragment=""设置组件名称
3.在各个有需求的html文件中使用导航栏组件
<div th:replace="~{/commons/commons::topbar}"></div>
<div th:replace="~{/commons/commons::sidebar}"></div>
th:replace=""使用组件,格式为~{组件所在文件路径::组件名}
1701

被折叠的 条评论
为什么被折叠?



