第一步去art-template的官网下载 模板引擎的js库文件 并将文件引入到页面中
<!-- 将模板引擎的库文件引入到页面中
-->
<script src
="../js/template-web.js"></script
>
第二步写一个script标签并设置id属性
<!-- 2.准备art
-template模板
-->
<!-- id用来区分
-->
<script type
="text/html" id
='tpl'>
<h1
>{{username
}}</h1
>
</script
>
第三步使用template方法告诉模板引擎将哪个数据和哪个标签进行拼接
<script tyepe
="text/javascript">
var html
= template('tpl', { username
: 'zs', age
: 30 })
console
.log(html
);
var body
= document
.getElementById('te');
body
.innerHTML
= html
;
</script
>