spring boot 怎么 html 嵌套 html?
? ? ? ?這幾天我在看admin方面的框架,發(fā)現(xiàn)很多框架里邊的html 都是寫在一起的,里邊的側(cè)邊欄和頁(yè)面都在一起?
怎么來處理這個(gè)問題?
?
官網(wǎng)的動(dòng)態(tài)組件是可以實(shí)現(xiàn)這個(gè)功能,但也不簡(jiǎn)單。
? ? ?3. react 的實(shí)現(xiàn) :https://reacttraining.com/react-router/web/example/sidebar?比vue簡(jiǎn)單方便。
? ? ? ? ?還有這個(gè)很有價(jià)值:
? ? ? ? ?https://github.com/booleanhunter/ReactJS-AdminLTE/blob/master/routes.js
? ? ? ? ?我現(xiàn)在喜歡這個(gè)方法,簡(jiǎn)潔、方便真的不錯(cuò)。
? ? ?4.?https://github.com/dsheiko/html-import? ?html-import 登場(chǎng)了。
? ? ? ? 如果想編譯就用npm吧,我直接用里邊的dist 里邊的html-import.es5.js 就可以了,而且ie 瀏覽器也可以支持,但是要求服務(wù)? ? ? ? ? 器運(yùn)行后才可以。
? ? ? ? 寫二個(gè)文件:a. index.html??import-foo.html? (來測(cè)試一下好不好用)
? ? ? ? index.html 內(nèi)容如下:
<!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <html><head><title>HTML Import Demo</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"><script src="html-import.es5.js"></script></head><body><div class="container"><h4>Import a single HTML file</h4><link rel="html-import" href="import-foo.html" ></div></body> </html>import-foo.html? 內(nèi)容如下:
<div class="alert alert-success" role="alert">Import FOO</div><div class="panel panel-default"><div class="panel-body"><h4>8888888</h4></div> </div>?b? 創(chuàng)建一個(gè)文件夾放在 spring booot resource/static 下邊
├── static
│?? └── pages
│?? ? ? ├── html-import.es5.js
│?? ? ? ├── import-foo.html
│?? ? ? └── index.html
c? ?在spring boot 的controller 里邊寫入這個(gè):
@GetMapping("/")public String greeting2(HttpServletRequest request,ModelMap map) {return "redirect:/pages/index.html";}d 運(yùn)行吧: localhost:8080/?
成功了!!!
小結(jié): firefox 是可以所見所得的,其它的一定要把服務(wù)器運(yùn)行后才可以正常見結(jié)果,同在發(fā)現(xiàn)firefox對(duì)標(biāo)準(zhǔn)支持的很好,也不用打什么開關(guān)之類的,chrome 是要打開個(gè)開關(guān)的, 用這個(gè)方法就可以不使用什么太復(fù)雜的技術(shù)來搭建框架了。
總結(jié)
以上是生活随笔為你收集整理的spring boot 怎么 html 嵌套 html?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 更新后的Hbuilder X 报错 er
- 下一篇: 电机拖动第一二章习题总结