JS中模板引擎的用法
1.art-template 是一個(gè)簡約、超快的模板引擎。
它采用作用域預(yù)聲明的技術(shù)來優(yōu)化模板渲染速度,從而獲得接近 JavaScript 極限的運(yùn)行性能,并且同時(shí)支持 NodeJS 和瀏覽器。
2.右鍵下載至本地

3.在本地引入<script?src="./art.js/template-web.js">(注意自己的路徑不要引錯(cuò))
4.引入<script?type="text/html"?id="aaa">(注意這里的id要寫的)
5.?<script?type="text/javascript">
告訴模板引擎將數(shù)據(jù)與哪個(gè)模板引擎拼接
let?html=?template('aaa',{username:"張三",age:"18"})
????????//?console.log(html)
???????document.getElementById('container').innerHTML=html
5?<div?id="container">
????????</div>
????????<script?src="./art.js/template-web.js">
????????</script>
????????<script?type="text/html"?id="aaa">
????????????<h1>{{username}}+{{age}}</h1>
????????</script>
????????<script?type="text/javascript">
???????let?html=?template('aaa',{username:"張三",age:"18"})
????????//?console.log(html)
???????document.getElementById('container').innerHTML=html
????????</script>(這是一個(gè)具體的小例子)