template.js初始尝试使用模版引擎,但是却无法加载,是需要别的配置什么的吗?
源码如下:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Index</title>
<script src="/userSystem/js/template.js"></script>
</head>
<body>
<div id="content">
</div>
<script id="test" type="text/html">
<h1>{{title}}</h1>
<ul>
{{each list as value i}}
<li>索引 {{i + 1}} :{{value}}</li>
{{/each}}
</ul>
</script>
<script>
var data = {
title: '标签',
list: ['文艺', '博客', '摄影', '电影', '民谣', '旅行', '吉他']
};
console.log(data);
var html = template('test', data);
console.log(html);
document.getElementById('content').innerHTML = html;
</script>
</div>
</body>
</html>
输出结果:
慕容3067478
相关分类