I created a mustache template that contains different json parts and I append data to it dynamically json array, but what I want to do is clear the template part before adding new data to it(我创建了一个包含不同json部分的小胡子模板,并向其动态添加json数组数据,但是我想做的是在向其添加新数据之前清除模板部分)
function loadTempalte(data){
var template = $('#template').html();
Mustache.parse(template);
for ( oneResult of data) {
var rendered = Mustache.render(template, {key1: oneResult.Auther.toString(),
key2: oneResult.book.toString()});
$('#result-block').append(rendered);
}
}
}
<script id="template" type="x-tmpl-mustache">
{{ author}}
<br>
{{book}}
<hr>
</div>
</script>
ask by Sabrina translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…