<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="./lib/js/jquery.min.js"></script>
<script src="./lib/js/art-template.js"></script>
<title>Document</title>
</head>
<body>
<div id="middle">
<!-- 在里面渲染真实数据 -->
</div>
<script type="text/html" id="article-detail">
{{each articles value index}}
<h3 class="title">{{value.title}}</h3>
<p class="content">{{#value.content}}</p>
{{/each}}
</script>
<script>
$.ajax({
type:'get',
url:'https://wwwxxxxxxxxxxxx',
data:{
xxxxxxxxxxxx
},
dataType:'JSON',
success:res => {
console.log(res);
const articles=res.Data[0];
console.log(articles);
const htmlStr=template('article-detail',articles);
$('#middle').html(htmlStr);
},
error:msg=>{
console.log(msg);
}
});
</script>
</body>
</html>