<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p id="content"></p>
<script src="jquery-2.2.3.js"></script>
<script src="template-web.js"></script>
<script src="render.js"></script>
<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: ['文艺', '博客', '摄影', '电影', '民谣', '旅行', '吉他']
};
var html = template.render('test', data);
document.getElementById('content').innerHTML = html;
</script>
</body>
</html>
ringa_lee2017-05-16 13:28:39
What error was reported? type="text/html" Should this be text/template? Is your data format correct?
伊谢尔伦2017-05-16 13:28:39
There is no need for render.js in artTemplate
The biggest mistake is this sentence
var html = template.render('test', data);
should be changed to
var html = template('test', data);